Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux

Pull s390 patches from Martin Schwidefsky:
"A couple of bug fixes, a debug change for qdio, an update for the
default config, and one small extension.

The watchdog module based on diagnose 0x288 is converted to the
watchdog API and it now works under LPAR as well"

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
s390/ccwgroup: use ccwgroup_ungroup wrapper
s390/ccwgroup: fix an uninitialized return code
s390/ccwgroup: obtain extra reference for asynchronous processing
qdio: Keep device-specific dbf entries
s390/compat: correct ucontext layout for high gprs
s390/cio: set device name as early as possible
s390: update default configuration
s390: avoid format strings leaking into names
s390/airq: silence lockdep warning
s390/watchdog: add support for LPAR operation (diag288)
s390/watchdog: use watchdog API
s390/sclp_vt220: Enable ASCII console per default
s390/qdio: replace shift loop by ilog2
s390/cio: silence lockdep warning
s390/uaccess: always load the kernel ASCE after task switch
s390/ap_bus: Make modules parameters visible in sysfs

+504 -455
+3 -2
arch/s390/configs/default_defconfig
··· 45 45 CONFIG_UNIXWARE_DISKLABEL=y 46 46 CONFIG_CFQ_GROUP_IOSCHED=y 47 47 CONFIG_DEFAULT_DEADLINE=y 48 - CONFIG_MARCH_Z9_109=y 48 + CONFIG_MARCH_Z196=y 49 + CONFIG_TUNE_ZEC12=y 49 50 CONFIG_NR_CPUS=256 50 51 CONFIG_PREEMPT=y 51 52 CONFIG_HZ_100=y ··· 241 240 CONFIG_NF_CONNTRACK_IPV4=m 242 241 # CONFIG_NF_CONNTRACK_PROC_COMPAT is not set 243 242 CONFIG_NF_TABLES_IPV4=m 244 - CONFIG_NFT_REJECT_IPV4=m 245 243 CONFIG_NFT_CHAIN_ROUTE_IPV4=m 246 244 CONFIG_NFT_CHAIN_NAT_IPV4=m 247 245 CONFIG_NF_TABLES_ARP=m ··· 456 456 CONFIG_WATCHDOG=y 457 457 CONFIG_WATCHDOG_NOWAYOUT=y 458 458 CONFIG_SOFT_WATCHDOG=m 459 + CONFIG_DIAG288_WATCHDOG=m 459 460 # CONFIG_HID is not set 460 461 # CONFIG_USB_SUPPORT is not set 461 462 CONFIG_INFINIBAND=m
+3 -2
arch/s390/configs/gcov_defconfig
··· 45 45 CONFIG_UNIXWARE_DISKLABEL=y 46 46 CONFIG_CFQ_GROUP_IOSCHED=y 47 47 CONFIG_DEFAULT_DEADLINE=y 48 - CONFIG_MARCH_Z9_109=y 48 + CONFIG_MARCH_Z196=y 49 + CONFIG_TUNE_ZEC12=y 49 50 CONFIG_NR_CPUS=256 50 51 CONFIG_HZ_100=y 51 52 CONFIG_MEMORY_HOTPLUG=y ··· 239 238 CONFIG_NF_CONNTRACK_IPV4=m 240 239 # CONFIG_NF_CONNTRACK_PROC_COMPAT is not set 241 240 CONFIG_NF_TABLES_IPV4=m 242 - CONFIG_NFT_REJECT_IPV4=m 243 241 CONFIG_NFT_CHAIN_ROUTE_IPV4=m 244 242 CONFIG_NFT_CHAIN_NAT_IPV4=m 245 243 CONFIG_NF_TABLES_ARP=m ··· 453 453 CONFIG_WATCHDOG=y 454 454 CONFIG_WATCHDOG_NOWAYOUT=y 455 455 CONFIG_SOFT_WATCHDOG=m 456 + CONFIG_DIAG288_WATCHDOG=m 456 457 # CONFIG_HID is not set 457 458 # CONFIG_USB_SUPPORT is not set 458 459 CONFIG_INFINIBAND=m
+3 -2
arch/s390/configs/performance_defconfig
··· 43 43 CONFIG_UNIXWARE_DISKLABEL=y 44 44 CONFIG_CFQ_GROUP_IOSCHED=y 45 45 CONFIG_DEFAULT_DEADLINE=y 46 - CONFIG_MARCH_Z9_109=y 46 + CONFIG_MARCH_Z196=y 47 + CONFIG_TUNE_ZEC12=y 47 48 CONFIG_NR_CPUS=256 48 49 CONFIG_HZ_100=y 49 50 CONFIG_MEMORY_HOTPLUG=y ··· 237 236 CONFIG_NF_CONNTRACK_IPV4=m 238 237 # CONFIG_NF_CONNTRACK_PROC_COMPAT is not set 239 238 CONFIG_NF_TABLES_IPV4=m 240 - CONFIG_NFT_REJECT_IPV4=m 241 239 CONFIG_NFT_CHAIN_ROUTE_IPV4=m 242 240 CONFIG_NFT_CHAIN_NAT_IPV4=m 243 241 CONFIG_NF_TABLES_ARP=m ··· 451 451 CONFIG_WATCHDOG=y 452 452 CONFIG_WATCHDOG_NOWAYOUT=y 453 453 CONFIG_SOFT_WATCHDOG=m 454 + CONFIG_DIAG288_WATCHDOG=m 454 455 # CONFIG_HID is not set 455 456 # CONFIG_USB_SUPPORT is not set 456 457 CONFIG_INFINIBAND=m
+2 -1
arch/s390/configs/zfcpdump_defconfig
··· 8 8 CONFIG_PARTITION_ADVANCED=y 9 9 CONFIG_IBM_PARTITION=y 10 10 CONFIG_DEFAULT_DEADLINE=y 11 - CONFIG_MARCH_Z9_109=y 11 + CONFIG_MARCH_Z196=y 12 + CONFIG_TUNE_ZEC12=y 12 13 # CONFIG_COMPAT is not set 13 14 CONFIG_NR_CPUS=2 14 15 # CONFIG_HOTPLUG_CPU is not set
+7 -1
arch/s390/defconfig
··· 135 135 CONFIG_LOCK_STAT=y 136 136 CONFIG_DEBUG_LOCKDEP=y 137 137 CONFIG_DEBUG_ATOMIC_SLEEP=y 138 - CONFIG_DEBUG_WRITECOUNT=y 139 138 CONFIG_DEBUG_LIST=y 139 + CONFIG_DEBUG_PI_LIST=y 140 140 CONFIG_DEBUG_SG=y 141 141 CONFIG_DEBUG_NOTIFIERS=y 142 142 CONFIG_PROVE_RCU=y ··· 199 199 CONFIG_CRYPTO_DES_S390=m 200 200 CONFIG_CRYPTO_AES_S390=m 201 201 CONFIG_CRC7=m 202 + # CONFIG_XZ_DEC_X86 is not set 203 + # CONFIG_XZ_DEC_POWERPC is not set 204 + # CONFIG_XZ_DEC_IA64 is not set 205 + # CONFIG_XZ_DEC_ARM is not set 206 + # CONFIG_XZ_DEC_ARMTHUMB is not set 207 + # CONFIG_XZ_DEC_SPARC is not set 202 208 CONFIG_CMM=m
+15 -16
arch/s390/include/asm/mmu_context.h
··· 33 33 34 34 static inline void set_user_asce(struct mm_struct *mm) 35 35 { 36 - pgd_t *pgd = mm->pgd; 37 - 38 - S390_lowcore.user_asce = mm->context.asce_bits | __pa(pgd); 39 - set_fs(current->thread.mm_segment); 36 + S390_lowcore.user_asce = mm->context.asce_bits | __pa(mm->pgd); 37 + if (current->thread.mm_segment.ar4) 38 + __ctl_load(S390_lowcore.user_asce, 7, 7); 40 39 set_cpu_flag(CIF_ASCE); 41 40 } 42 41 ··· 69 70 /* Clear old ASCE by loading the kernel ASCE. */ 70 71 __ctl_load(S390_lowcore.kernel_asce, 1, 1); 71 72 __ctl_load(S390_lowcore.kernel_asce, 7, 7); 72 - /* Delay loading of the new ASCE to control registers CR1 & CR7 */ 73 - set_cpu_flag(CIF_ASCE); 74 73 atomic_inc(&next->context.attach_count); 75 74 atomic_dec(&prev->context.attach_count); 76 75 if (MACHINE_HAS_TLB_LC) 77 76 cpumask_clear_cpu(cpu, &prev->context.cpu_attach_mask); 77 + S390_lowcore.user_asce = next->context.asce_bits | __pa(next->pgd); 78 78 } 79 79 80 80 #define finish_arch_post_lock_switch finish_arch_post_lock_switch ··· 82 84 struct task_struct *tsk = current; 83 85 struct mm_struct *mm = tsk->mm; 84 86 85 - if (!mm) 86 - return; 87 - preempt_disable(); 88 - while (atomic_read(&mm->context.attach_count) >> 16) 89 - cpu_relax(); 87 + load_kernel_asce(); 88 + if (mm) { 89 + preempt_disable(); 90 + while (atomic_read(&mm->context.attach_count) >> 16) 91 + cpu_relax(); 90 92 91 - cpumask_set_cpu(smp_processor_id(), mm_cpumask(mm)); 92 - set_user_asce(mm); 93 - if (mm->context.flush_mm) 94 - __tlb_flush_mm(mm); 95 - preempt_enable(); 93 + cpumask_set_cpu(smp_processor_id(), mm_cpumask(mm)); 94 + if (mm->context.flush_mm) 95 + __tlb_flush_mm(mm); 96 + preempt_enable(); 97 + } 98 + set_fs(current->thread.mm_segment); 96 99 } 97 100 98 101 #define enter_lazy_tlb(mm,tsk) do { } while (0)
-4
arch/s390/include/asm/switch_to.h
··· 134 134 prev = __switch_to(prev,next); \ 135 135 } while (0) 136 136 137 - #define finish_arch_switch(prev) do { \ 138 - set_fs(current->thread.mm_segment); \ 139 - } while (0) 140 - 141 137 #endif /* __ASM_SWITCH_TO_H */
+6 -2
arch/s390/include/uapi/asm/ucontext.h
··· 16 16 struct ucontext *uc_link; 17 17 stack_t uc_stack; 18 18 _sigregs uc_mcontext; 19 - unsigned long uc_sigmask[2]; 19 + sigset_t uc_sigmask; 20 + /* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */ 21 + unsigned char __unused[128 - sizeof(sigset_t)]; 20 22 unsigned long uc_gprs_high[16]; 21 23 }; 22 24 ··· 29 27 struct ucontext *uc_link; 30 28 stack_t uc_stack; 31 29 _sigregs uc_mcontext; 32 - sigset_t uc_sigmask; /* mask last for extensibility */ 30 + sigset_t uc_sigmask; 31 + /* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */ 32 + unsigned char __unused[128 - sizeof(sigset_t)]; 33 33 }; 34 34 35 35 #endif /* !_ASM_S390_UCONTEXT_H */
+3 -1
arch/s390/kernel/compat_linux.h
··· 69 69 __u32 uc_link; /* pointer */ 70 70 compat_stack_t uc_stack; 71 71 _sigregs32 uc_mcontext; 72 - compat_sigset_t uc_sigmask; /* mask last for extensibility */ 72 + compat_sigset_t uc_sigmask; 73 + /* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */ 74 + unsigned char __unused[128 - sizeof(compat_sigset_t)]; 73 75 }; 74 76 75 77 struct stat64_emu31;
+1 -1
drivers/s390/block/dcssblk.c
··· 593 593 dev_info->start = dcssblk_find_lowest_addr(dev_info); 594 594 dev_info->end = dcssblk_find_highest_addr(dev_info); 595 595 596 - dev_set_name(&dev_info->dev, dev_info->segment_name); 596 + dev_set_name(&dev_info->dev, "%s", dev_info->segment_name); 597 597 dev_info->dev.release = dcssblk_release_segment; 598 598 dev_info->dev.groups = dcssblk_dev_attr_groups; 599 599 INIT_LIST_HEAD(&dev_info->lh);
-1
drivers/s390/char/Makefile
··· 19 19 obj-$(CONFIG_SCLP_CPI) += sclp_cpi.o 20 20 obj-$(CONFIG_SCLP_ASYNC) += sclp_async.o 21 21 22 - obj-$(CONFIG_ZVM_WATCHDOG) += vmwatchdog.o 23 22 obj-$(CONFIG_VMLOGRDR) += vmlogrdr.o 24 23 obj-$(CONFIG_VMCP) += vmcp.o 25 24
-2
drivers/s390/char/sclp_vt220.c
··· 838 838 { 839 839 int rc; 840 840 841 - if (!CONSOLE_IS_SCLP) 842 - return 0; 843 841 rc = __sclp_vt220_init(sclp_console_pages); 844 842 if (rc) 845 843 return rc;
+1 -1
drivers/s390/char/vmlogrdr.c
··· 761 761 762 762 dev = kzalloc(sizeof(struct device), GFP_KERNEL); 763 763 if (dev) { 764 - dev_set_name(dev, priv->internal_name); 764 + dev_set_name(dev, "%s", priv->internal_name); 765 765 dev->bus = &iucv_bus; 766 766 dev->parent = iucv_root; 767 767 dev->driver = &vmlogrdr_driver;
-338
drivers/s390/char/vmwatchdog.c
··· 1 - /* 2 - * Watchdog implementation based on z/VM Watchdog Timer API 3 - * 4 - * Copyright IBM Corp. 2004, 2009 5 - * 6 - * The user space watchdog daemon can use this driver as 7 - * /dev/vmwatchdog to have z/VM execute the specified CP 8 - * command when the timeout expires. The default command is 9 - * "IPL", which which cause an immediate reboot. 10 - */ 11 - #define KMSG_COMPONENT "vmwatchdog" 12 - #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 13 - 14 - #include <linux/init.h> 15 - #include <linux/fs.h> 16 - #include <linux/kernel.h> 17 - #include <linux/miscdevice.h> 18 - #include <linux/module.h> 19 - #include <linux/moduleparam.h> 20 - #include <linux/slab.h> 21 - #include <linux/suspend.h> 22 - #include <linux/watchdog.h> 23 - 24 - #include <asm/ebcdic.h> 25 - #include <asm/io.h> 26 - #include <asm/uaccess.h> 27 - 28 - #define MAX_CMDLEN 240 29 - #define MIN_INTERVAL 15 30 - static char vmwdt_cmd[MAX_CMDLEN] = "IPL"; 31 - static bool vmwdt_conceal; 32 - 33 - static bool vmwdt_nowayout = WATCHDOG_NOWAYOUT; 34 - 35 - MODULE_LICENSE("GPL"); 36 - MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>"); 37 - MODULE_DESCRIPTION("z/VM Watchdog Timer"); 38 - module_param_string(cmd, vmwdt_cmd, MAX_CMDLEN, 0644); 39 - MODULE_PARM_DESC(cmd, "CP command that is run when the watchdog triggers"); 40 - module_param_named(conceal, vmwdt_conceal, bool, 0644); 41 - MODULE_PARM_DESC(conceal, "Enable the CONCEAL CP option while the watchdog " 42 - " is active"); 43 - module_param_named(nowayout, vmwdt_nowayout, bool, 0); 44 - MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started" 45 - " (default=CONFIG_WATCHDOG_NOWAYOUT)"); 46 - MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 47 - 48 - static unsigned int vmwdt_interval = 60; 49 - static unsigned long vmwdt_is_open; 50 - static int vmwdt_expect_close; 51 - 52 - static DEFINE_MUTEX(vmwdt_mutex); 53 - 54 - #define VMWDT_OPEN 0 /* devnode is open or suspend in progress */ 55 - #define VMWDT_RUNNING 1 /* The watchdog is armed */ 56 - 57 - enum vmwdt_func { 58 - /* function codes */ 59 - wdt_init = 0, 60 - wdt_change = 1, 61 - wdt_cancel = 2, 62 - /* flags */ 63 - wdt_conceal = 0x80000000, 64 - }; 65 - 66 - static int __diag288(enum vmwdt_func func, unsigned int timeout, 67 - char *cmd, size_t len) 68 - { 69 - register unsigned long __func asm("2") = func; 70 - register unsigned long __timeout asm("3") = timeout; 71 - register unsigned long __cmdp asm("4") = virt_to_phys(cmd); 72 - register unsigned long __cmdl asm("5") = len; 73 - int err; 74 - 75 - err = -EINVAL; 76 - asm volatile( 77 - " diag %1,%3,0x288\n" 78 - "0: la %0,0\n" 79 - "1:\n" 80 - EX_TABLE(0b,1b) 81 - : "+d" (err) : "d"(__func), "d"(__timeout), 82 - "d"(__cmdp), "d"(__cmdl) : "1", "cc"); 83 - return err; 84 - } 85 - 86 - static int vmwdt_keepalive(void) 87 - { 88 - /* we allocate new memory every time to avoid having 89 - * to track the state. static allocation is not an 90 - * option since that might not be contiguous in real 91 - * storage in case of a modular build */ 92 - static char *ebc_cmd; 93 - size_t len; 94 - int ret; 95 - unsigned int func; 96 - 97 - ebc_cmd = kmalloc(MAX_CMDLEN, GFP_KERNEL); 98 - if (!ebc_cmd) 99 - return -ENOMEM; 100 - 101 - len = strlcpy(ebc_cmd, vmwdt_cmd, MAX_CMDLEN); 102 - ASCEBC(ebc_cmd, MAX_CMDLEN); 103 - EBC_TOUPPER(ebc_cmd, MAX_CMDLEN); 104 - 105 - func = vmwdt_conceal ? (wdt_init | wdt_conceal) : wdt_init; 106 - set_bit(VMWDT_RUNNING, &vmwdt_is_open); 107 - ret = __diag288(func, vmwdt_interval, ebc_cmd, len); 108 - WARN_ON(ret != 0); 109 - kfree(ebc_cmd); 110 - return ret; 111 - } 112 - 113 - static int vmwdt_disable(void) 114 - { 115 - char cmd[] = {'\0'}; 116 - int ret = __diag288(wdt_cancel, 0, cmd, 0); 117 - WARN_ON(ret != 0); 118 - clear_bit(VMWDT_RUNNING, &vmwdt_is_open); 119 - return ret; 120 - } 121 - 122 - static int __init vmwdt_probe(void) 123 - { 124 - /* there is no real way to see if the watchdog is supported, 125 - * so we try initializing it with a NOP command ("BEGIN") 126 - * that won't cause any harm even if the following disable 127 - * fails for some reason */ 128 - char ebc_begin[] = { 129 - 194, 197, 199, 201, 213 130 - }; 131 - if (__diag288(wdt_init, 15, ebc_begin, sizeof(ebc_begin)) != 0) 132 - return -EINVAL; 133 - return vmwdt_disable(); 134 - } 135 - 136 - static int vmwdt_open(struct inode *i, struct file *f) 137 - { 138 - int ret; 139 - if (test_and_set_bit(VMWDT_OPEN, &vmwdt_is_open)) 140 - return -EBUSY; 141 - ret = vmwdt_keepalive(); 142 - if (ret) 143 - clear_bit(VMWDT_OPEN, &vmwdt_is_open); 144 - return ret ? ret : nonseekable_open(i, f); 145 - } 146 - 147 - static int vmwdt_close(struct inode *i, struct file *f) 148 - { 149 - if (vmwdt_expect_close == 42) 150 - vmwdt_disable(); 151 - vmwdt_expect_close = 0; 152 - clear_bit(VMWDT_OPEN, &vmwdt_is_open); 153 - return 0; 154 - } 155 - 156 - static struct watchdog_info vmwdt_info = { 157 - .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, 158 - .firmware_version = 0, 159 - .identity = "z/VM Watchdog Timer", 160 - }; 161 - 162 - static int __vmwdt_ioctl(unsigned int cmd, unsigned long arg) 163 - { 164 - switch (cmd) { 165 - case WDIOC_GETSUPPORT: 166 - if (copy_to_user((void __user *)arg, &vmwdt_info, 167 - sizeof(vmwdt_info))) 168 - return -EFAULT; 169 - return 0; 170 - case WDIOC_GETSTATUS: 171 - case WDIOC_GETBOOTSTATUS: 172 - return put_user(0, (int __user *)arg); 173 - case WDIOC_GETTEMP: 174 - return -EINVAL; 175 - case WDIOC_SETOPTIONS: 176 - { 177 - int options, ret; 178 - if (get_user(options, (int __user *)arg)) 179 - return -EFAULT; 180 - ret = -EINVAL; 181 - if (options & WDIOS_DISABLECARD) { 182 - ret = vmwdt_disable(); 183 - if (ret) 184 - return ret; 185 - } 186 - if (options & WDIOS_ENABLECARD) { 187 - ret = vmwdt_keepalive(); 188 - } 189 - return ret; 190 - } 191 - case WDIOC_GETTIMEOUT: 192 - return put_user(vmwdt_interval, (int __user *)arg); 193 - case WDIOC_SETTIMEOUT: 194 - { 195 - int interval; 196 - if (get_user(interval, (int __user *)arg)) 197 - return -EFAULT; 198 - if (interval < MIN_INTERVAL) 199 - return -EINVAL; 200 - vmwdt_interval = interval; 201 - } 202 - return vmwdt_keepalive(); 203 - case WDIOC_KEEPALIVE: 204 - return vmwdt_keepalive(); 205 - } 206 - return -EINVAL; 207 - } 208 - 209 - static long vmwdt_ioctl(struct file *f, unsigned int cmd, unsigned long arg) 210 - { 211 - int rc; 212 - 213 - mutex_lock(&vmwdt_mutex); 214 - rc = __vmwdt_ioctl(cmd, arg); 215 - mutex_unlock(&vmwdt_mutex); 216 - return (long) rc; 217 - } 218 - 219 - static ssize_t vmwdt_write(struct file *f, const char __user *buf, 220 - size_t count, loff_t *ppos) 221 - { 222 - if(count) { 223 - if (!vmwdt_nowayout) { 224 - size_t i; 225 - 226 - /* note: just in case someone wrote the magic character 227 - * five months ago... */ 228 - vmwdt_expect_close = 0; 229 - 230 - for (i = 0; i != count; i++) { 231 - char c; 232 - if (get_user(c, buf+i)) 233 - return -EFAULT; 234 - if (c == 'V') 235 - vmwdt_expect_close = 42; 236 - } 237 - } 238 - /* someone wrote to us, we should restart timer */ 239 - vmwdt_keepalive(); 240 - } 241 - return count; 242 - } 243 - 244 - static int vmwdt_resume(void) 245 - { 246 - clear_bit(VMWDT_OPEN, &vmwdt_is_open); 247 - return NOTIFY_DONE; 248 - } 249 - 250 - /* 251 - * It makes no sense to go into suspend while the watchdog is running. 252 - * Depending on the memory size, the watchdog might trigger, while we 253 - * are still saving the memory. 254 - * We reuse the open flag to ensure that suspend and watchdog open are 255 - * exclusive operations 256 - */ 257 - static int vmwdt_suspend(void) 258 - { 259 - if (test_and_set_bit(VMWDT_OPEN, &vmwdt_is_open)) { 260 - pr_err("The system cannot be suspended while the watchdog" 261 - " is in use\n"); 262 - return notifier_from_errno(-EBUSY); 263 - } 264 - if (test_bit(VMWDT_RUNNING, &vmwdt_is_open)) { 265 - clear_bit(VMWDT_OPEN, &vmwdt_is_open); 266 - pr_err("The system cannot be suspended while the watchdog" 267 - " is running\n"); 268 - return notifier_from_errno(-EBUSY); 269 - } 270 - return NOTIFY_DONE; 271 - } 272 - 273 - /* 274 - * This function is called for suspend and resume. 275 - */ 276 - static int vmwdt_power_event(struct notifier_block *this, unsigned long event, 277 - void *ptr) 278 - { 279 - switch (event) { 280 - case PM_POST_HIBERNATION: 281 - case PM_POST_SUSPEND: 282 - return vmwdt_resume(); 283 - case PM_HIBERNATION_PREPARE: 284 - case PM_SUSPEND_PREPARE: 285 - return vmwdt_suspend(); 286 - default: 287 - return NOTIFY_DONE; 288 - } 289 - } 290 - 291 - static struct notifier_block vmwdt_power_notifier = { 292 - .notifier_call = vmwdt_power_event, 293 - }; 294 - 295 - static const struct file_operations vmwdt_fops = { 296 - .open = &vmwdt_open, 297 - .release = &vmwdt_close, 298 - .unlocked_ioctl = &vmwdt_ioctl, 299 - .write = &vmwdt_write, 300 - .owner = THIS_MODULE, 301 - .llseek = noop_llseek, 302 - }; 303 - 304 - static struct miscdevice vmwdt_dev = { 305 - .minor = WATCHDOG_MINOR, 306 - .name = "watchdog", 307 - .fops = &vmwdt_fops, 308 - }; 309 - 310 - static int __init vmwdt_init(void) 311 - { 312 - int ret; 313 - 314 - ret = vmwdt_probe(); 315 - if (ret) 316 - return ret; 317 - ret = register_pm_notifier(&vmwdt_power_notifier); 318 - if (ret) 319 - return ret; 320 - /* 321 - * misc_register() has to be the last action in module_init(), because 322 - * file operations will be available right after this. 323 - */ 324 - ret = misc_register(&vmwdt_dev); 325 - if (ret) { 326 - unregister_pm_notifier(&vmwdt_power_notifier); 327 - return ret; 328 - } 329 - return 0; 330 - } 331 - module_init(vmwdt_init); 332 - 333 - static void __exit vmwdt_exit(void) 334 - { 335 - unregister_pm_notifier(&vmwdt_power_notifier); 336 - misc_deregister(&vmwdt_dev); 337 - } 338 - module_exit(vmwdt_exit);
+6 -7
drivers/s390/cio/airq.c
··· 196 196 */ 197 197 unsigned long airq_iv_alloc(struct airq_iv *iv, unsigned long num) 198 198 { 199 - unsigned long bit, i; 199 + unsigned long bit, i, flags; 200 200 201 201 if (!iv->avail || num == 0) 202 202 return -1UL; 203 - spin_lock(&iv->lock); 203 + spin_lock_irqsave(&iv->lock, flags); 204 204 bit = find_first_bit_inv(iv->avail, iv->bits); 205 205 while (bit + num <= iv->bits) { 206 206 for (i = 1; i < num; i++) ··· 218 218 } 219 219 if (bit + num > iv->bits) 220 220 bit = -1UL; 221 - spin_unlock(&iv->lock); 221 + spin_unlock_irqrestore(&iv->lock, flags); 222 222 return bit; 223 - 224 223 } 225 224 EXPORT_SYMBOL(airq_iv_alloc); 226 225 ··· 231 232 */ 232 233 void airq_iv_free(struct airq_iv *iv, unsigned long bit, unsigned long num) 233 234 { 234 - unsigned long i; 235 + unsigned long i, flags; 235 236 236 237 if (!iv->avail || num == 0) 237 238 return; 238 - spin_lock(&iv->lock); 239 + spin_lock_irqsave(&iv->lock, flags); 239 240 for (i = 0; i < num; i++) { 240 241 /* Clear (possibly left over) interrupt bit */ 241 242 clear_bit_inv(bit + i, iv->vector); ··· 247 248 while (iv->end > 0 && !test_bit_inv(iv->end - 1, iv->avail)) 248 249 iv->end--; 249 250 } 250 - spin_unlock(&iv->lock); 251 + spin_unlock_irqrestore(&iv->lock, flags); 251 252 } 252 253 EXPORT_SYMBOL(airq_iv_free); 253 254
+11 -17
drivers/s390/cio/ccwgroup.c
··· 184 184 const char *buf, size_t count) 185 185 { 186 186 struct ccwgroup_device *gdev = to_ccwgroupdev(dev); 187 - int rc; 187 + int rc = 0; 188 188 189 189 /* Prevent concurrent online/offline processing and ungrouping. */ 190 190 if (atomic_cmpxchg(&gdev->onoff, 0, 1) != 0) ··· 196 196 197 197 if (device_remove_file_self(dev, attr)) 198 198 ccwgroup_ungroup(gdev); 199 + else 200 + rc = -ENODEV; 199 201 out: 200 202 if (rc) { 201 - if (rc != -EAGAIN) 202 - /* Release onoff "lock" when ungrouping failed. */ 203 - atomic_set(&gdev->onoff, 0); 203 + /* Release onoff "lock" when ungrouping failed. */ 204 + atomic_set(&gdev->onoff, 0); 204 205 return rc; 205 206 } 206 207 return count; ··· 228 227 container_of(work, struct ccwgroup_device, ungroup_work); 229 228 230 229 ccwgroup_ungroup(gdev); 230 + put_device(&gdev->dev); 231 231 } 232 232 233 233 static void ccwgroup_release(struct device *dev) ··· 414 412 { 415 413 struct ccwgroup_device *gdev = to_ccwgroupdev(data); 416 414 417 - if (action == BUS_NOTIFY_UNBIND_DRIVER) 415 + if (action == BUS_NOTIFY_UNBIND_DRIVER) { 416 + get_device(&gdev->dev); 418 417 schedule_work(&gdev->ungroup_work); 418 + } 419 419 420 420 return NOTIFY_OK; 421 421 } ··· 586 582 __ccwgroup_match_all))) { 587 583 struct ccwgroup_device *gdev = to_ccwgroupdev(dev); 588 584 589 - mutex_lock(&gdev->reg_mutex); 590 - __ccwgroup_remove_symlinks(gdev); 591 - device_unregister(dev); 592 - __ccwgroup_remove_cdev_refs(gdev); 593 - mutex_unlock(&gdev->reg_mutex); 585 + ccwgroup_ungroup(gdev); 594 586 put_device(dev); 595 587 } 596 588 driver_unregister(&cdriver->driver); ··· 633 633 get_device(&gdev->dev); 634 634 spin_unlock_irq(cdev->ccwlock); 635 635 /* Unregister group device. */ 636 - mutex_lock(&gdev->reg_mutex); 637 - if (device_is_registered(&gdev->dev)) { 638 - __ccwgroup_remove_symlinks(gdev); 639 - device_unregister(&gdev->dev); 640 - __ccwgroup_remove_cdev_refs(gdev); 641 - } 642 - mutex_unlock(&gdev->reg_mutex); 636 + ccwgroup_ungroup(gdev); 643 637 /* Release ccwgroup device reference for local processing. */ 644 638 put_device(&gdev->dev); 645 639 }
+2
drivers/s390/cio/cio.c
··· 602 602 603 603 #ifdef CONFIG_CCW_CONSOLE 604 604 static struct subchannel *console_sch; 605 + static struct lock_class_key console_sch_key; 605 606 606 607 /* 607 608 * Use cio_tsch to update the subchannel status and call the interrupt handler ··· 687 686 if (IS_ERR(sch)) 688 687 return sch; 689 688 689 + lockdep_set_class(sch->lock, &console_sch_key); 690 690 isc_register(CONSOLE_ISC); 691 691 sch->config.isc = CONSOLE_ISC; 692 692 sch->config.intparm = (u32)(addr_t)sch;
+36 -35
drivers/s390/cio/device.c
··· 678 678 NULL, 679 679 }; 680 680 681 - /* this is a simple abstraction for device_register that sets the 682 - * correct bus type and adds the bus specific files */ 683 - static int ccw_device_register(struct ccw_device *cdev) 681 + static int ccw_device_add(struct ccw_device *cdev) 684 682 { 685 683 struct device *dev = &cdev->dev; 686 - int ret; 687 684 688 685 dev->bus = &ccw_bus_type; 689 - ret = dev_set_name(&cdev->dev, "0.%x.%04x", cdev->private->dev_id.ssid, 690 - cdev->private->dev_id.devno); 691 - if (ret) 692 - return ret; 693 686 return device_add(dev); 694 687 } 695 688 ··· 757 764 static int io_subchannel_initialize_dev(struct subchannel *sch, 758 765 struct ccw_device *cdev) 759 766 { 760 - cdev->private->cdev = cdev; 761 - cdev->private->int_class = IRQIO_CIO; 762 - atomic_set(&cdev->private->onoff, 0); 767 + struct ccw_device_private *priv = cdev->private; 768 + int ret; 769 + 770 + priv->cdev = cdev; 771 + priv->int_class = IRQIO_CIO; 772 + priv->state = DEV_STATE_NOT_OPER; 773 + priv->dev_id.devno = sch->schib.pmcw.dev; 774 + priv->dev_id.ssid = sch->schid.ssid; 775 + priv->schid = sch->schid; 776 + 777 + INIT_WORK(&priv->todo_work, ccw_device_todo); 778 + INIT_LIST_HEAD(&priv->cmb_list); 779 + init_waitqueue_head(&priv->wait_q); 780 + init_timer(&priv->timer); 781 + 782 + atomic_set(&priv->onoff, 0); 783 + cdev->ccwlock = sch->lock; 763 784 cdev->dev.parent = &sch->dev; 764 785 cdev->dev.release = ccw_device_release; 765 - INIT_WORK(&cdev->private->todo_work, ccw_device_todo); 766 786 cdev->dev.groups = ccwdev_attr_groups; 767 787 /* Do first half of device_register. */ 768 788 device_initialize(&cdev->dev); 789 + ret = dev_set_name(&cdev->dev, "0.%x.%04x", cdev->private->dev_id.ssid, 790 + cdev->private->dev_id.devno); 791 + if (ret) 792 + goto out_put; 769 793 if (!get_device(&sch->dev)) { 770 - /* Release reference from device_initialize(). */ 771 - put_device(&cdev->dev); 772 - return -ENODEV; 794 + ret = -ENODEV; 795 + goto out_put; 773 796 } 774 - cdev->private->flags.initialized = 1; 797 + priv->flags.initialized = 1; 798 + spin_lock_irq(sch->lock); 799 + sch_set_cdev(sch, cdev); 800 + spin_unlock_irq(sch->lock); 775 801 return 0; 802 + 803 + out_put: 804 + /* Release reference from device_initialize(). */ 805 + put_device(&cdev->dev); 806 + return ret; 776 807 } 777 808 778 809 static struct ccw_device * io_subchannel_create_ccwdev(struct subchannel *sch) ··· 875 858 dev_set_uevent_suppress(&sch->dev, 0); 876 859 kobject_uevent(&sch->dev.kobj, KOBJ_ADD); 877 860 /* make it known to the system */ 878 - ret = ccw_device_register(cdev); 861 + ret = ccw_device_add(cdev); 879 862 if (ret) { 880 863 CIO_MSG_EVENT(0, "Could not register ccw dev 0.%x.%04x: %d\n", 881 864 cdev->private->dev_id.ssid, ··· 940 923 941 924 static void io_subchannel_recog(struct ccw_device *cdev, struct subchannel *sch) 942 925 { 943 - struct ccw_device_private *priv; 944 - 945 - cdev->ccwlock = sch->lock; 946 - 947 - /* Init private data. */ 948 - priv = cdev->private; 949 - priv->dev_id.devno = sch->schib.pmcw.dev; 950 - priv->dev_id.ssid = sch->schid.ssid; 951 - priv->schid = sch->schid; 952 - priv->state = DEV_STATE_NOT_OPER; 953 - INIT_LIST_HEAD(&priv->cmb_list); 954 - init_waitqueue_head(&priv->wait_q); 955 - init_timer(&priv->timer); 956 - 957 926 /* Increase counter of devices currently in recognition. */ 958 927 atomic_inc(&ccw_device_init_count); 959 928 960 929 /* Start async. device sensing. */ 961 930 spin_lock_irq(sch->lock); 962 - sch_set_cdev(sch, cdev); 963 931 ccw_device_recognition(cdev); 964 932 spin_unlock_irq(sch->lock); 965 933 } ··· 1085 1083 dev_set_uevent_suppress(&sch->dev, 0); 1086 1084 kobject_uevent(&sch->dev.kobj, KOBJ_ADD); 1087 1085 cdev = sch_get_cdev(sch); 1088 - rc = ccw_device_register(cdev); 1086 + rc = ccw_device_add(cdev); 1089 1087 if (rc) { 1090 1088 /* Release online reference. */ 1091 1089 put_device(&cdev->dev); ··· 1599 1597 if (rc) 1600 1598 return rc; 1601 1599 sch->driver = &io_subchannel_driver; 1602 - sch_set_cdev(sch, cdev); 1603 1600 io_subchannel_recog(cdev, sch); 1604 1601 /* Now wait for the async. recognition to come to an end. */ 1605 1602 spin_lock_irq(cdev->ccwlock); ··· 1640 1639 put_device(&sch->dev); 1641 1640 return ERR_PTR(-ENOMEM); 1642 1641 } 1642 + set_io_private(sch, io_priv); 1643 1643 cdev = io_subchannel_create_ccwdev(sch); 1644 1644 if (IS_ERR(cdev)) { 1645 1645 put_device(&sch->dev); ··· 1648 1646 return cdev; 1649 1647 } 1650 1648 cdev->drv = drv; 1651 - set_io_private(sch, io_priv); 1652 1649 ccw_device_set_int_class(cdev); 1653 1650 return cdev; 1654 1651 }
+72 -7
drivers/s390/cio/qdio_debug.c
··· 7 7 #include <linux/debugfs.h> 8 8 #include <linux/uaccess.h> 9 9 #include <linux/export.h> 10 + #include <linux/slab.h> 10 11 #include <asm/debug.h> 11 12 #include "qdio_debug.h" 12 13 #include "qdio.h" ··· 17 16 18 17 static struct dentry *debugfs_root; 19 18 #define QDIO_DEBUGFS_NAME_LEN 10 19 + #define QDIO_DBF_NAME_LEN 20 20 20 21 - void qdio_allocate_dbf(struct qdio_initialize *init_data, 21 + struct qdio_dbf_entry { 22 + char dbf_name[QDIO_DBF_NAME_LEN]; 23 + debug_info_t *dbf_info; 24 + struct list_head dbf_list; 25 + }; 26 + 27 + static LIST_HEAD(qdio_dbf_list); 28 + static DEFINE_MUTEX(qdio_dbf_list_mutex); 29 + 30 + static debug_info_t *qdio_get_dbf_entry(char *name) 31 + { 32 + struct qdio_dbf_entry *entry; 33 + debug_info_t *rc = NULL; 34 + 35 + mutex_lock(&qdio_dbf_list_mutex); 36 + list_for_each_entry(entry, &qdio_dbf_list, dbf_list) { 37 + if (strcmp(entry->dbf_name, name) == 0) { 38 + rc = entry->dbf_info; 39 + break; 40 + } 41 + } 42 + mutex_unlock(&qdio_dbf_list_mutex); 43 + return rc; 44 + } 45 + 46 + static void qdio_clear_dbf_list(void) 47 + { 48 + struct qdio_dbf_entry *entry, *tmp; 49 + 50 + mutex_lock(&qdio_dbf_list_mutex); 51 + list_for_each_entry_safe(entry, tmp, &qdio_dbf_list, dbf_list) { 52 + list_del(&entry->dbf_list); 53 + debug_unregister(entry->dbf_info); 54 + kfree(entry); 55 + } 56 + mutex_unlock(&qdio_dbf_list_mutex); 57 + } 58 + 59 + int qdio_allocate_dbf(struct qdio_initialize *init_data, 22 60 struct qdio_irq *irq_ptr) 23 61 { 24 - char text[20]; 62 + char text[QDIO_DBF_NAME_LEN]; 63 + struct qdio_dbf_entry *new_entry; 25 64 26 65 DBF_EVENT("qfmt:%1d", init_data->q_format); 27 66 DBF_HEX(init_data->adapter_name, 8); ··· 79 38 DBF_EVENT("irq:%8lx", (unsigned long)irq_ptr); 80 39 81 40 /* allocate trace view for the interface */ 82 - snprintf(text, 20, "qdio_%s", dev_name(&init_data->cdev->dev)); 83 - irq_ptr->debug_area = debug_register(text, 2, 1, 16); 84 - debug_register_view(irq_ptr->debug_area, &debug_hex_ascii_view); 85 - debug_set_level(irq_ptr->debug_area, DBF_WARN); 86 - DBF_DEV_EVENT(DBF_ERR, irq_ptr, "dbf created"); 41 + snprintf(text, QDIO_DBF_NAME_LEN, "qdio_%s", 42 + dev_name(&init_data->cdev->dev)); 43 + irq_ptr->debug_area = qdio_get_dbf_entry(text); 44 + if (irq_ptr->debug_area) 45 + DBF_DEV_EVENT(DBF_ERR, irq_ptr, "dbf reused"); 46 + else { 47 + irq_ptr->debug_area = debug_register(text, 2, 1, 16); 48 + if (!irq_ptr->debug_area) 49 + return -ENOMEM; 50 + if (debug_register_view(irq_ptr->debug_area, 51 + &debug_hex_ascii_view)) { 52 + debug_unregister(irq_ptr->debug_area); 53 + return -ENOMEM; 54 + } 55 + debug_set_level(irq_ptr->debug_area, DBF_WARN); 56 + DBF_DEV_EVENT(DBF_ERR, irq_ptr, "dbf created"); 57 + new_entry = kzalloc(sizeof(struct qdio_dbf_entry), GFP_KERNEL); 58 + if (!new_entry) { 59 + debug_unregister(irq_ptr->debug_area); 60 + return -ENOMEM; 61 + } 62 + strlcpy(new_entry->dbf_name, text, QDIO_DBF_NAME_LEN); 63 + new_entry->dbf_info = irq_ptr->debug_area; 64 + mutex_lock(&qdio_dbf_list_mutex); 65 + list_add(&new_entry->dbf_list, &qdio_dbf_list); 66 + mutex_unlock(&qdio_dbf_list_mutex); 67 + } 68 + return 0; 87 69 } 88 70 89 71 static int qstat_show(struct seq_file *m, void *v) ··· 364 300 365 301 void qdio_debug_exit(void) 366 302 { 303 + qdio_clear_dbf_list(); 367 304 debugfs_remove(debugfs_root); 368 305 if (qdio_dbf_setup) 369 306 debug_unregister(qdio_dbf_setup);
+1 -1
drivers/s390/cio/qdio_debug.h
··· 75 75 } 76 76 } 77 77 78 - void qdio_allocate_dbf(struct qdio_initialize *init_data, 78 + int qdio_allocate_dbf(struct qdio_initialize *init_data, 79 79 struct qdio_irq *irq_ptr); 80 80 void qdio_setup_debug_entries(struct qdio_irq *irq_ptr, 81 81 struct ccw_device *cdev);
+7 -9
drivers/s390/cio/qdio_main.c
··· 409 409 set_buf_state(q, q->u.in.ack_start, SLSB_P_INPUT_NOT_INIT); 410 410 } 411 411 412 - static inline void account_sbals(struct qdio_q *q, int count) 412 + static inline void account_sbals(struct qdio_q *q, unsigned int count) 413 413 { 414 - int pos = 0; 414 + int pos; 415 415 416 416 q->q_stats.nr_sbal_total += count; 417 417 if (count == QDIO_MAX_BUFFERS_MASK) { 418 418 q->q_stats.nr_sbals[7]++; 419 419 return; 420 420 } 421 - while (count >>= 1) 422 - pos++; 421 + pos = ilog2(count); 423 422 q->q_stats.nr_sbals[pos]++; 424 423 } 425 424 ··· 1233 1234 return -ENODEV; 1234 1235 1235 1236 DBF_EVENT("qfree:%4x", cdev->private->schid.sch_no); 1237 + DBF_DEV_EVENT(DBF_ERR, irq_ptr, "dbf abandoned"); 1236 1238 mutex_lock(&irq_ptr->setup_mutex); 1237 1239 1238 - if (irq_ptr->debug_area != NULL) { 1239 - debug_unregister(irq_ptr->debug_area); 1240 - irq_ptr->debug_area = NULL; 1241 - } 1240 + irq_ptr->debug_area = NULL; 1242 1241 cdev->private->qdio_data = NULL; 1243 1242 mutex_unlock(&irq_ptr->setup_mutex); 1244 1243 ··· 1273 1276 goto out_err; 1274 1277 1275 1278 mutex_init(&irq_ptr->setup_mutex); 1276 - qdio_allocate_dbf(init_data, irq_ptr); 1279 + if (qdio_allocate_dbf(init_data, irq_ptr)) 1280 + goto out_rel; 1277 1281 1278 1282 /* 1279 1283 * Allocate a page for the chsc calls in qdio_establish.
+2 -2
drivers/s390/crypto/ap_bus.c
··· 77 77 * Module parameter 78 78 */ 79 79 int ap_domain_index = -1; /* Adjunct Processor Domain Index */ 80 - module_param_named(domain, ap_domain_index, int, 0000); 80 + module_param_named(domain, ap_domain_index, int, S_IRUSR|S_IRGRP); 81 81 MODULE_PARM_DESC(domain, "domain index for ap devices"); 82 82 EXPORT_SYMBOL(ap_domain_index); 83 83 84 84 static int ap_thread_flag = 0; 85 - module_param_named(poll_thread, ap_thread_flag, int, 0000); 85 + module_param_named(poll_thread, ap_thread_flag, int, S_IRUSR|S_IRGRP); 86 86 MODULE_PARM_DESC(poll_thread, "Turn on/off poll thread, default is 0 (off)."); 87 87 88 88 static struct device *ap_root_device = NULL;
+1 -1
drivers/s390/crypto/zcrypt_api.c
··· 356 356 357 357 zops = __ops_lookup(name, variant); 358 358 if (!zops) { 359 - request_module(name); 359 + request_module("%s", name); 360 360 zops = __ops_lookup(name, variant); 361 361 } 362 362 if ((!zops) || (!try_module_get(zops->owner)))
+5 -2
drivers/watchdog/Kconfig
··· 1280 1280 1281 1281 # S390 Architecture 1282 1282 1283 - config ZVM_WATCHDOG 1284 - tristate "z/VM Watchdog Timer" 1283 + config DIAG288_WATCHDOG 1284 + tristate "System z diag288 Watchdog" 1285 1285 depends on S390 1286 + select WATCHDOG_CORE 1286 1287 help 1287 1288 IBM s/390 and zSeries machines running under z/VM 5.1 or later 1288 1289 provide a virtual watchdog timer to their guest that cause a 1289 1290 user define Control Program command to be executed after a 1290 1291 timeout. 1292 + LPAR provides a very similar interface. This driver handles 1293 + both. 1291 1294 1292 1295 To compile this driver as a module, choose M here. The module 1293 1296 will be called vmwatchdog.
+1
drivers/watchdog/Makefile
··· 153 153 obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o 154 154 155 155 # S390 Architecture 156 + obj-$(CONFIG_DIAG288_WATCHDOG) += diag288_wdt.o 156 157 157 158 # SUPERH (sh + sh64) Architecture 158 159 obj-$(CONFIG_SH_WDT) += shwdt.o
+316
drivers/watchdog/diag288_wdt.c
··· 1 + /* 2 + * Watchdog driver for z/VM and LPAR using the diag 288 interface. 3 + * 4 + * Under z/VM, expiration of the watchdog will send a "system restart" command 5 + * to CP. 6 + * 7 + * The command can be altered using the module parameter "cmd". This is 8 + * not recommended because it's only supported on z/VM but not whith LPAR. 9 + * 10 + * On LPAR, the watchdog will always trigger a system restart. the module 11 + * paramter cmd is meaningless here. 12 + * 13 + * 14 + * Copyright IBM Corp. 2004, 2013 15 + * Author(s): Arnd Bergmann (arndb@de.ibm.com) 16 + * Philipp Hachtmann (phacht@de.ibm.com) 17 + * 18 + */ 19 + 20 + #define KMSG_COMPONENT "diag288_wdt" 21 + #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 22 + 23 + #include <linux/init.h> 24 + #include <linux/kernel.h> 25 + #include <linux/module.h> 26 + #include <linux/moduleparam.h> 27 + #include <linux/slab.h> 28 + #include <linux/miscdevice.h> 29 + #include <linux/watchdog.h> 30 + #include <linux/suspend.h> 31 + #include <asm/ebcdic.h> 32 + #include <linux/io.h> 33 + #include <linux/uaccess.h> 34 + 35 + #define MAX_CMDLEN 240 36 + #define DEFAULT_CMD "SYSTEM RESTART" 37 + 38 + #define MIN_INTERVAL 15 /* Minimal time supported by diag88 */ 39 + #define MAX_INTERVAL 3600 /* One hour should be enough - pure estimation */ 40 + 41 + #define WDT_DEFAULT_TIMEOUT 30 42 + 43 + /* Function codes - init, change, cancel */ 44 + #define WDT_FUNC_INIT 0 45 + #define WDT_FUNC_CHANGE 1 46 + #define WDT_FUNC_CANCEL 2 47 + #define WDT_FUNC_CONCEAL 0x80000000 48 + 49 + /* Action codes for LPAR watchdog */ 50 + #define LPARWDT_RESTART 0 51 + 52 + static char wdt_cmd[MAX_CMDLEN] = DEFAULT_CMD; 53 + static bool conceal_on; 54 + static bool nowayout_info = WATCHDOG_NOWAYOUT; 55 + 56 + MODULE_LICENSE("GPL"); 57 + MODULE_AUTHOR("Arnd Bergmann <arndb@de.ibm.com>"); 58 + MODULE_AUTHOR("Philipp Hachtmann <phacht@de.ibm.com>"); 59 + 60 + MODULE_DESCRIPTION("System z diag288 Watchdog Timer"); 61 + 62 + module_param_string(cmd, wdt_cmd, MAX_CMDLEN, 0644); 63 + MODULE_PARM_DESC(cmd, "CP command that is run when the watchdog triggers (z/VM only)"); 64 + 65 + module_param_named(conceal, conceal_on, bool, 0644); 66 + MODULE_PARM_DESC(conceal, "Enable the CONCEAL CP option while the watchdog is active (z/VM only)"); 67 + 68 + module_param_named(nowayout, nowayout_info, bool, 0444); 69 + MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default = CONFIG_WATCHDOG_NOWAYOUT)"); 70 + 71 + MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); 72 + MODULE_ALIAS("vmwatchdog"); 73 + 74 + static int __diag288(unsigned int func, unsigned int timeout, 75 + unsigned long action, unsigned int len) 76 + { 77 + register unsigned long __func asm("2") = func; 78 + register unsigned long __timeout asm("3") = timeout; 79 + register unsigned long __action asm("4") = action; 80 + register unsigned long __len asm("5") = len; 81 + int err; 82 + 83 + err = -EINVAL; 84 + asm volatile( 85 + " diag %1, %3, 0x288\n" 86 + "0: la %0, 0\n" 87 + "1:\n" 88 + EX_TABLE(0b, 1b) 89 + : "+d" (err) : "d"(__func), "d"(__timeout), 90 + "d"(__action), "d"(__len) : "1", "cc"); 91 + return err; 92 + } 93 + 94 + static int __diag288_vm(unsigned int func, unsigned int timeout, 95 + char *cmd, size_t len) 96 + { 97 + return __diag288(func, timeout, virt_to_phys(cmd), len); 98 + } 99 + 100 + static int __diag288_lpar(unsigned int func, unsigned int timeout, 101 + unsigned long action) 102 + { 103 + return __diag288(func, timeout, action, 0); 104 + } 105 + 106 + static int wdt_start(struct watchdog_device *dev) 107 + { 108 + char *ebc_cmd; 109 + size_t len; 110 + int ret; 111 + unsigned int func; 112 + 113 + ret = -ENODEV; 114 + 115 + if (MACHINE_IS_VM) { 116 + ebc_cmd = kmalloc(MAX_CMDLEN, GFP_KERNEL); 117 + if (!ebc_cmd) 118 + return -ENOMEM; 119 + len = strlcpy(ebc_cmd, wdt_cmd, MAX_CMDLEN); 120 + ASCEBC(ebc_cmd, MAX_CMDLEN); 121 + EBC_TOUPPER(ebc_cmd, MAX_CMDLEN); 122 + 123 + func = conceal_on ? (WDT_FUNC_INIT | WDT_FUNC_CONCEAL) 124 + : WDT_FUNC_INIT; 125 + ret = __diag288_vm(func, dev->timeout, ebc_cmd, len); 126 + WARN_ON(ret != 0); 127 + kfree(ebc_cmd); 128 + } 129 + 130 + if (MACHINE_IS_LPAR) { 131 + ret = __diag288_lpar(WDT_FUNC_INIT, 132 + dev->timeout, LPARWDT_RESTART); 133 + } 134 + 135 + if (ret) { 136 + pr_err("The watchdog cannot be activated\n"); 137 + return ret; 138 + } 139 + pr_info("The watchdog was activated\n"); 140 + return 0; 141 + } 142 + 143 + static int wdt_stop(struct watchdog_device *dev) 144 + { 145 + int ret; 146 + 147 + ret = __diag288(WDT_FUNC_CANCEL, 0, 0, 0); 148 + pr_info("The watchdog was deactivated\n"); 149 + return ret; 150 + } 151 + 152 + static int wdt_ping(struct watchdog_device *dev) 153 + { 154 + char *ebc_cmd; 155 + size_t len; 156 + int ret; 157 + unsigned int func; 158 + 159 + ret = -ENODEV; 160 + 161 + if (MACHINE_IS_VM) { 162 + ebc_cmd = kmalloc(MAX_CMDLEN, GFP_KERNEL); 163 + if (!ebc_cmd) 164 + return -ENOMEM; 165 + len = strlcpy(ebc_cmd, wdt_cmd, MAX_CMDLEN); 166 + ASCEBC(ebc_cmd, MAX_CMDLEN); 167 + EBC_TOUPPER(ebc_cmd, MAX_CMDLEN); 168 + 169 + /* 170 + * It seems to be ok to z/VM to use the init function to 171 + * retrigger the watchdog. On LPAR WDT_FUNC_CHANGE must 172 + * be used when the watchdog is running. 173 + */ 174 + func = conceal_on ? (WDT_FUNC_INIT | WDT_FUNC_CONCEAL) 175 + : WDT_FUNC_INIT; 176 + 177 + ret = __diag288_vm(func, dev->timeout, ebc_cmd, len); 178 + WARN_ON(ret != 0); 179 + kfree(ebc_cmd); 180 + } 181 + 182 + if (MACHINE_IS_LPAR) 183 + ret = __diag288_lpar(WDT_FUNC_CHANGE, dev->timeout, 0); 184 + 185 + if (ret) 186 + pr_err("The watchdog timer cannot be started or reset\n"); 187 + return ret; 188 + } 189 + 190 + static int wdt_set_timeout(struct watchdog_device * dev, unsigned int new_to) 191 + { 192 + dev->timeout = new_to; 193 + return wdt_ping(dev); 194 + } 195 + 196 + static struct watchdog_ops wdt_ops = { 197 + .owner = THIS_MODULE, 198 + .start = wdt_start, 199 + .stop = wdt_stop, 200 + .ping = wdt_ping, 201 + .set_timeout = wdt_set_timeout, 202 + }; 203 + 204 + static struct watchdog_info wdt_info = { 205 + .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, 206 + .firmware_version = 0, 207 + .identity = "z Watchdog", 208 + }; 209 + 210 + static struct watchdog_device wdt_dev = { 211 + .parent = NULL, 212 + .info = &wdt_info, 213 + .ops = &wdt_ops, 214 + .bootstatus = 0, 215 + .timeout = WDT_DEFAULT_TIMEOUT, 216 + .min_timeout = MIN_INTERVAL, 217 + .max_timeout = MAX_INTERVAL, 218 + }; 219 + 220 + /* 221 + * It makes no sense to go into suspend while the watchdog is running. 222 + * Depending on the memory size, the watchdog might trigger, while we 223 + * are still saving the memory. 224 + * We reuse the open flag to ensure that suspend and watchdog open are 225 + * exclusive operations 226 + */ 227 + static int wdt_suspend(void) 228 + { 229 + if (test_and_set_bit(WDOG_DEV_OPEN, &wdt_dev.status)) { 230 + pr_err("Linux cannot be suspended while the watchdog is in use\n"); 231 + return notifier_from_errno(-EBUSY); 232 + } 233 + if (test_bit(WDOG_ACTIVE, &wdt_dev.status)) { 234 + clear_bit(WDOG_DEV_OPEN, &wdt_dev.status); 235 + pr_err("Linux cannot be suspended while the watchdog is in use\n"); 236 + return notifier_from_errno(-EBUSY); 237 + } 238 + return NOTIFY_DONE; 239 + } 240 + 241 + static int wdt_resume(void) 242 + { 243 + clear_bit(WDOG_DEV_OPEN, &wdt_dev.status); 244 + return NOTIFY_DONE; 245 + } 246 + 247 + static int wdt_power_event(struct notifier_block *this, unsigned long event, 248 + void *ptr) 249 + { 250 + switch (event) { 251 + case PM_POST_HIBERNATION: 252 + case PM_POST_SUSPEND: 253 + return wdt_resume(); 254 + case PM_HIBERNATION_PREPARE: 255 + case PM_SUSPEND_PREPARE: 256 + return wdt_suspend(); 257 + default: 258 + return NOTIFY_DONE; 259 + } 260 + } 261 + 262 + static struct notifier_block wdt_power_notifier = { 263 + .notifier_call = wdt_power_event, 264 + }; 265 + 266 + static int __init diag288_init(void) 267 + { 268 + int ret; 269 + char ebc_begin[] = { 270 + 194, 197, 199, 201, 213 271 + }; 272 + 273 + watchdog_set_nowayout(&wdt_dev, nowayout_info); 274 + 275 + if (MACHINE_IS_VM) { 276 + pr_info("The watchdog device driver detected a z/VM environment\n"); 277 + if (__diag288_vm(WDT_FUNC_INIT, 15, 278 + ebc_begin, sizeof(ebc_begin)) != 0) { 279 + pr_err("The watchdog cannot be initialized\n"); 280 + return -EINVAL; 281 + } 282 + } else if (MACHINE_IS_LPAR) { 283 + pr_info("The watchdog device driver detected an LPAR environment\n"); 284 + if (__diag288_lpar(WDT_FUNC_INIT, 30, LPARWDT_RESTART)) { 285 + pr_err("The watchdog cannot be initialized\n"); 286 + return -EINVAL; 287 + } 288 + } else { 289 + pr_err("Linux runs in an environment that does not support the diag288 watchdog\n"); 290 + return -ENODEV; 291 + } 292 + 293 + if (__diag288_lpar(WDT_FUNC_CANCEL, 0, 0)) { 294 + pr_err("The watchdog cannot be deactivated\n"); 295 + return -EINVAL; 296 + } 297 + 298 + ret = register_pm_notifier(&wdt_power_notifier); 299 + if (ret) 300 + return ret; 301 + 302 + ret = watchdog_register_device(&wdt_dev); 303 + if (ret) 304 + unregister_pm_notifier(&wdt_power_notifier); 305 + 306 + return ret; 307 + } 308 + 309 + static void __exit diag288_exit(void) 310 + { 311 + watchdog_unregister_device(&wdt_dev); 312 + unregister_pm_notifier(&wdt_power_notifier); 313 + } 314 + 315 + module_init(diag288_init); 316 + module_exit(diag288_exit);