s390 patches for the next merge window (2.6.33)
Subsystems (7)
cover s390 patches for the next merge window (2.6.33)
Greetings,
the current patch queue on git390 for the next merge window. 52 patches, over half of them (27) are for the common-io-layer rework. 6 patches for the optimization of the fault handler, another 6 for the new cex3 crypto cards and some other stuff. As always, have fun ..
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.
PATCH 1/52 Improve address space check.
From: Martin Schwidefsky <[email protected]>
A data access in access-register mode always is a user mode access, the code to inspect the access-registers can be removed. The second change is to use a different test to check for no-execute fault. The third change is to pass the translation exception identification as parameter, in theory the trans_exc_code in the lowcore could have been overwritten by the time the call to check_space from do_no_context is done.
---
arch/s390/mm/fault.c | 99 +++++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 54 deletions(-)
arch/s390/mm/fault.c +45 -54
@@ -100,39 +100,28 @@/* * Returns the address space associated with the fault. -* Returns 0 for kernel space, 1 for user space and -* 2 for code execution in user space with noexec=on. +* Returns 0 for kernel space and 1 for user space. */ -static inline int check_space (struct task_struct *tsk) +static inline int user_space_fault (unsigned long trans_exc_code) {/* -* The lowest two bits of S390_lowcore.trans_exc_code -* indicate which paging table was used. +* The lowest two bits of the translation exception +* identification indicate which paging table was used. */ -int desc = S390_lowcore.trans_exc_code &3 ; - -if (desc ==3 )/* Home Segment Table Descriptor */ -return switch_amode ==0 ; -if (desc ==2 )/* Secondary Segment Table Descriptor */ -return tsk->thread.mm_segment.ar4; -#ifdef CONFIG_S390_SWITCH_AMODE -if (unlikely (desc ==1 )) {/* STD determined via access register */ -/* %a0 always indicates primary space. */ -if (S390_lowcore.exc_access_id !=0 ) { -save_access_regs (tsk->thread.acrs); -/* -* An alet of 0 indicates primary space. -* An alet of 1 indicates secondary space. -* Any other alet values generate an -* alen-translation exception. -*/ -if (tsk->thread.acrs[S390_lowcore.exc_access_id]) -return tsk->thread.mm_segment.ar4; - } - } -#endif -/* Primary Segment Table Descriptor */ -return switch_amode << s390_noexec; + trans_exc_code &=3 ; +if (trans_exc_code ==2 ) +/* Access via secondary space, set_fs setting decides */ +return current->thread.mm_segment.ar4; +if (!switch_amode) +/* User space if the access has been done via home space. */ +return trans_exc_code ==3 ; +/* +* If the user space is not the home space the kernel runs in home +* space. Access via secondary space has already been covered, +* access via primary space or access register is from user space +* and access via home space is from the kernel. +*/ +return trans_exc_code !=3 ; }/*
@@ -162,9 +151,10 @@ }static void do_no_context (struct pt_regs *regs,unsigned long error_code, -unsigned long address) +unsigned long trans_exc_code) {const struct exception_table_entry *fixup; +unsigned long address;/* Are we prepared to handle this kernel fault? */ fixup =search_exception_tables (regs->psw.addr & __FIXUP_MASK);
@@ -177,7 +167,8 @@* Oops. The kernel tried to access some bad page. We'll have to * terminate things with extreme prejudice. */ -if (check_space (current) ==0 ) + address = trans_exc_code & __FAIL_ADDR_MASK; +if (user_space_fault (trans_exc_code) ==0 )printk (KERN_ALERT "Unable to handle kernel pointer dereference" " at virtual kernel address %p\n" , (void *)address);else
@@ -188,7 +179,8 @@do_exit (SIGKILL ); } -static void do_low_address (struct pt_regs *regs,unsigned long error_code) +static void do_low_address (struct pt_regs *regs,unsigned long error_code, +unsigned long trans_exc_code) {/* Low-address protection hit in kernel mode means NULL pointer write access in kernel mode. */
@@ -198,11 +190,11 @@do_exit (SIGKILL ); } -do_no_context (regs, error_code,0 ); +do_no_context (regs, error_code, trans_exc_code); }static void do_sigbus (struct pt_regs *regs,unsigned long error_code, -unsigned long address) +unsigned long trans_exc_code) {struct task_struct *tsk = current;struct mm_struct *mm = tsk->mm;
@@ -212,13 +204,13 @@* Send a sigbus, regardless of whether we were in kernel * or user mode. */ - tsk->thread.prot_addr = address; + tsk->thread.prot_addr = trans_exc_code & __FAIL_ADDR_MASK; tsk->thread.trap_no = error_code;force_sig (SIGBUS , tsk);/* Kernel mode? Handle exceptions or die */ if (!(regs->psw.mask &PSW_MASK_PSTATE )) -do_no_context (regs, error_code, address); +do_no_context (regs, error_code, trans_exc_code); }#ifdef CONFIG_S390_EXEC_PROTECT
@@ -272,13 +264,13 @@* 3b Region third trans. -> Not present (nullification) */ static inline void -do_exception (struct pt_regs *regs,unsigned long error_code,int write) +do_exception (struct pt_regs *regs,unsigned long error_code,int write, +unsigned long trans_exc_code) {struct task_struct *tsk;struct mm_struct *mm;struct vm_area_struct *vma;unsigned long address; -int space;int si_code;int fault;
@@ -288,18 +280,15 @@ tsk = current; mm = tsk->mm; -/* get the failing address and the affected space */ - address = S390_lowcore.trans_exc_code & __FAIL_ADDR_MASK; - space =check_space (tsk); -/* * Verify that the fault happened in user space, that * we are not in an interrupt and that there is a * user context. */ -if (unlikely (space ==0 ||in_atomic () || !mm)) +if (unlikely (!user_space_fault (trans_exc_code) ||in_atomic () || !mm)) goto no_context; + address = trans_exc_code & __FAIL_ADDR_MASK;/* * When we get here, the fault happened in the current * task's user address space, so we can switch on the
@@ -315,7 +304,8 @@ goto bad_area;#ifdef CONFIG_S390_EXEC_PROTECT -if (unlikely ((space ==2 ) && !(vma->vm_flags &VM_EXEC ))) +if (unlikely ((regs->psw.mask &PSW_MASK_ASC ) ==PSW_ASC_SECONDARY && + (trans_exc_code &3 ) ==0 && !(vma->vm_flags &VM_EXEC )))if (!signal_return (mm, regs, address, error_code))/* * signal_return() has done an up_read(&mm->mmap_sem)
@@ -397,12 +387,14 @@ } no_context: -do_no_context (regs, error_code, address); +do_no_context (regs, error_code, trans_exc_code); }void __kprobes do_protection_exception (struct pt_regs *regs,long error_code) { +unsigned long trans_exc_code = S390_lowcore.trans_exc_code; +/* Protection exception is supressing, decrement psw address. */ regs->psw.addr -= (error_code >>16 );/*
@@ -410,31 +402,30 @@* as a special case because the translation exception code * field is not guaranteed to contain valid data in this case. */ -if (unlikely (!(S390_lowcore.trans_exc_code &4 ))) { -do_low_address (regs, error_code); +if (unlikely (!(trans_exc_code &4 ))) { +do_low_address (regs, error_code, trans_exc_code);return ; } -do_exception (regs,4 ,1 ); +do_exception (regs,4 ,1 , trans_exc_code); }void __kprobes do_dat_exception (struct pt_regs *regs,long error_code) { -do_exception (regs, error_code &0xff ,0 ); +do_exception (regs, error_code &0xff ,0 , S390_lowcore.trans_exc_code); }#ifdef CONFIG_64BIT void __kprobes do_asce_exception (struct pt_regs *regs,unsigned long error_code) { +unsigned long trans_exc_code = S390_lowcore.trans_exc_code;struct mm_struct *mm;struct vm_area_struct *vma;unsigned long address; -int space; mm = current->mm; - address = S390_lowcore.trans_exc_code & __FAIL_ADDR_MASK; - space =check_space (current); + address = trans_exc_code & __FAIL_ADDR_MASK; -if (unlikely (space ==0 ||in_atomic () || !mm)) +if (unlikely (!user_space_fault (trans_exc_code) ||in_atomic () || !mm)) goto no_context;local_irq_enable ();
@@ -457,7 +448,7 @@ } no_context: -do_no_context (regs, error_code, address); +do_no_context (regs, error_code, trans_exc_code); }#endif
PATCH 2/52 Improve address space mode selection.
In reply to Martin SchwidefskyFrom: Martin Schwidefsky <[email protected]>
Introduce user_mode to replace the two variables switch_amode and s390_noexec. There are three valid combinations of the old values:
1) switch_amode == 0 && s390_noexec == 0
2) switch_amode == 1 && s390_noexec == 0
3) switch_amode == 1 && s390_noexec == 1
They get replaced by
1) user_mode == HOME_SPACE_MODE
2) user_mode == PRIMARY_SPACE_MODE
3) user_mode == SECONDARY_SPACE_MODE
The new kernel parameter user_mode=[primary,secondary,home] lets you choose the address space mode the user space processes should use. In addition the CONFIG_S390_SWITCH_AMODE config option is removed.
---
arch/s390/Kconfig | 15 --------------- arch/s390/defconfig | 1 - arch/s390/include/asm/mmu_context.h | 4 ++-- arch/s390/include/asm/pgalloc.h | 3 ++- arch/s390/include/asm/setup.h | 17 ++++++----------- arch/s390/kernel/setup.c | 36 ++++++++++++++++++++---------------- arch/s390/kernel/vdso.c | 9 +++++---- arch/s390/kvm/Kconfig | 1 - arch/s390/lib/uaccess_mvcos.c | 4 ---- arch/s390/mm/fault.c | 4 ++-- arch/s390/mm/pgtable.c | 2 +- 11 files changed, 38 insertions(+), 58 deletions(-)
arch/s390/defconfig +0 -1
@@ -185,7 +185,6 @@ CONFIG_COMPAT=y CONFIG_SYSVIPC_COMPAT=y CONFIG_AUDIT_ARCH=y -CONFIG_S390_SWITCH_AMODE=y CONFIG_S390_EXEC_PROTECT=y #
arch/s390/include/asm/mmu_context.h +2 -2
@@ -36,7 +36,7 @@ mm->context.has_pgste =1 ; mm->context.alloc_pgste =1 ; }else { - mm->context.noexec = s390_noexec; + mm->context.noexec = (user_mode ==SECONDARY_SPACE_MODE ); mm->context.has_pgste =0 ; mm->context.alloc_pgste =0 ; }
@@ -58,7 +58,7 @@pgd_t *pgd = mm->pgd; S390_lowcore.user_asce = mm->context.asce_bits |__pa (pgd); -if (switch_amode) { +if (user_mode !=HOME_SPACE_MODE ) {/* Load primary space page table origin. */ pgd = mm->context.noexec ?get_shadow_table (pgd) : pgd; S390_lowcore.user_exec_asce = mm->context.asce_bits |__pa (pgd);
arch/s390/include/asm/pgalloc.h +2 -1
@@ -143,7 +143,8 @@spin_lock_init (&mm->context.list_lock);INIT_LIST_HEAD (&mm->context.crst_list);INIT_LIST_HEAD (&mm->context.pgtable_list); -return (pgd_t *)crst_table_alloc (mm, s390_noexec); +return (pgd_t *) +crst_table_alloc (mm, user_mode ==SECONDARY_SPACE_MODE ); }#define pgd_free (mm, pgd) crst_table_free(mm, (unsigned long *) pgd)
arch/s390/include/asm/setup.h +6 -11
@@ -49,17 +49,12 @@void detect_memory_layout (struct mem_chunk chunk[]); -#ifdef CONFIG_S390_SWITCH_AMODE -extern unsigned int switch_amode; -#else -#define switch_amode (0) -#endif - -#ifdef CONFIG_S390_EXEC_PROTECT -extern unsigned int s390_noexec; -#else -#define s390_noexec (0) -#endif +#define PRIMARY_SPACE_MODE 0 +#define ACCESS_REGISTER_MODE 1 +#define SECONDARY_SPACE_MODE 2 +#define HOME_SPACE_MODE 3 + +extern unsigned int user_mode;/* * Machine features detected in head.S
arch/s390/Kconfig +0 -15
@@ -192,23 +192,8 @@ bool default y -config S390_SWITCH_AMODE - bool "Switch kernel/user addressing modes" - help - This option allows to switch the addressing modes of kernel and user - space. The kernel parameter switch_amode=on will enable this feature, - default is disabled. Enabling this (via kernel parameter) on machines - earlier than IBM System z9-109 EC/BC will reduce system performance. - - Note that this option will also be selected by selecting the execute - protection option below. Enabling the execute protection via the - noexec kernel parameter will also switch the addressing modes, - independent of the switch_amode kernel parameter. - - config S390_EXEC_PROTECT bool "Data execute protection" - select S390_SWITCH_AMODE help This option allows to enable a buffer overflow protection for user space programs and it also selects the addressing mode option above.
arch/s390/kernel/setup.c +20 -16
@@ -305,9 +305,8 @@ }early_param ("mem" , early_parse_mem); -#ifdef CONFIG_S390_SWITCH_AMODE -unsigned int switch_amode =0 ; -EXPORT_SYMBOL_GPL (switch_amode); +unsigned int user_mode =HOME_SPACE_MODE ; +EXPORT_SYMBOL_GPL (user_mode);static int set_amode_and_uaccess (unsigned long user_amode,unsigned long user32_amode)
@@ -340,23 +339,29 @@*/ static int __init early_parse_switch_amode (char *p) { - switch_amode =1 ; +if (user_mode !=SECONDARY_SPACE_MODE ) + user_mode =PRIMARY_SPACE_MODE ;return 0 ; }early_param ("switch_amode" , early_parse_switch_amode); -#else /* CONFIG_S390_SWITCH_AMODE */ -static inline int set_amode_and_uaccess (unsigned long user_amode, -unsigned long user32_amode) +static int __init early_parse_user_mode (char *p) { +if (p &&strcmp (p,"primary" ) ==0 ) + user_mode =PRIMARY_SPACE_MODE ; +#ifdef CONFIG_S390_EXEC_PROTECT + else if (p && strcmp(p, "secondary") == 0) + user_mode = SECONDARY_SPACE_MODE; +#endif + else if (!p || strcmp(p, "home") == 0) + user_mode =HOME_SPACE_MODE ; + else + return 1;return 0 ; } -#endif /* CONFIG_S390_SWITCH_AMODE */ +early_param ("user_mode" , early_parse_user_mode);#ifdef CONFIG_S390_EXEC_PROTECT -unsigned int s390_noexec =0 ; -EXPORT_SYMBOL_GPL (s390_noexec); -/* * Enable execute protection? */
@@ -364,8 +369,7 @@ {if (!strncmp (p,"off" ,3 ))return 0 ; - switch_amode =1 ; - s390_noexec =1 ; + user_mode =SECONDARY_SPACE_MODE ;return 0 ; }early_param ("noexec" , early_parse_noexec);
@@ -373,7 +377,7 @@static void setup_addressing_mode (void ) { -if (s390_noexec) { +if (user_mode ==SECONDARY_SPACE_MODE ) {if (set_amode_and_uaccess (PSW_ASC_SECONDARY ,PSW32_ASC_SECONDARY )) pr_info("Execute protection active, "
@@ -381,7 +385,7 @@else pr_info ("Execute protection active, " "mvcos not available\n" ); - }else if (switch_amode) { + }else if (user_mode ==PRIMARY_SPACE_MODE ) {if (set_amode_and_uaccess (PSW_ASC_PRIMARY ,PSW32_ASC_PRIMARY ))pr_info ("Address spaces switched, " "mvcos available\n" );
@@ -411,7 +415,7 @@ lc->restart_psw.mask =PSW_BASE_BITS |PSW_DEFAULT_KEY ; lc->restart_psw.addr =PSW_ADDR_AMODE | (unsigned long ) restart_int_handler; -if (switch_amode) +if (user_mode !=HOME_SPACE_MODE ) lc->restart_psw.mask |=PSW_ASC_HOME ; lc->external_new_psw.mask = psw_kernel_bits; lc->external_new_psw.addr =
arch/s390/kernel/vdso.c +5 -4
@@ -86,7 +86,8 @@unsigned int facility_list; facility_list =stfl (); - vd->ectg_available = switch_amode && (facility_list &1 ); + vd->ectg_available = + user_mode !=HOME_SPACE_MODE && (facility_list &1 ); }#ifdef CONFIG_64BIT
@@ -114,7 +115,7 @@ lowcore->vdso_per_cpu_data = __LC_PASTE; -if (!switch_amode || !vdso_enabled) +if (user_mode ==HOME_SPACE_MODE || !vdso_enabled)return 0 ; segment_table =__get_free_pages (GFP_KERNEL ,SEGMENT_ORDER );
@@ -160,7 +161,7 @@unsigned long segment_table, page_table, page_frame;u32 *psal, *aste; -if (!switch_amode || !vdso_enabled) +if (user_mode ==HOME_SPACE_MODE || !vdso_enabled)return ; psal = (u32 *)(addr_t ) lowcore->paste[4 ];
@@ -184,7 +185,7 @@static void vdso_init_cr5 (void ) { -if (switch_amode && vdso_enabled) +if (user_mode !=HOME_SPACE_MODE && vdso_enabled)on_each_cpu (__vdso_init_cr5,NULL ,1 ); }#endif /* CONFIG_64BIT */
arch/s390/kvm/Kconfig +0 -1
@@ -20,7 +20,6 @@ depends on HAVE_KVM && EXPERIMENTAL select PREEMPT_NOTIFIERS select ANON_INODES - select S390_SWITCH_AMODE ---help--- Support hosting paravirtualized guest machines using the SIE virtualization capability on the mainframe. This should work
arch/s390/lib/uaccess_mvcos.c +0 -4
@@ -162,7 +162,6 @@return size; } -#ifdef CONFIG_S390_SWITCH_AMODE static size_t strnlen_user_mvcos (size_t count,const char __user *src) {char buf[256 ];
@@ -200,7 +199,6 @@ }while ((len_str == len) && (done < count));return done; } -#endif /* CONFIG_S390_SWITCH_AMODE */ struct uaccess_ops uaccess_mvcos = { .copy_from_user = copy_from_user_mvcos_check,
@@ -215,7 +213,6 @@ .futex_atomic_cmpxchg = futex_atomic_cmpxchg_std, }; -#ifdef CONFIG_S390_SWITCH_AMODE struct uaccess_ops uaccess_mvcos_switch = { .copy_from_user = copy_from_user_mvcos, .copy_from_user_small = copy_from_user_mvcos,
@@ -228,4 +225,3 @@ .futex_atomic_op = futex_atomic_op_pt, .futex_atomic_cmpxchg = futex_atomic_cmpxchg_pt, }; -#endif
arch/s390/mm/fault.c +2 -2
@@ -112,7 +112,7 @@if (trans_exc_code ==2 )/* Access via secondary space, set_fs setting decides */ return current->thread.mm_segment.ar4; -if (!switch_amode) +if (user_mode ==HOME_SPACE_MODE )/* User space if the access has been done via home space. */ return trans_exc_code ==3 ;/*
@@ -168,7 +168,7 @@* terminate things with extreme prejudice. */ address = trans_exc_code & __FAIL_ADDR_MASK; -if (user_space_fault (trans_exc_code) ==0 ) +if (!user_space_fault (trans_exc_code))printk (KERN_ALERT "Unable to handle kernel pointer dereference" " at virtual kernel address %p\n" , (void *)address);else
arch/s390/mm/pgtable.c +1 -1
@@ -269,7 +269,7 @@struct mm_struct *mm, *old_mm;/* Do we have switched amode? If no, we cannot do sie */ -if (!switch_amode) +if (user_mode ==HOME_SPACE_MODE )return -EINVAL ;/* Do we have pgstes? if yes, we are done */
PATCH 3/52 Improve notify_page_fault implementation.
In reply to Martin SchwidefskyFrom: Martin Schwidefsky <[email protected]>
notify_page_fault does a preempt_disable/preempt_enable for each fault generated by a kernel access to user space. If kprobes is not active that is unnecessary since the interrupts are not reenabled yet. To play safe repeat the kprobe_running check after preempt_disable().
---
arch/s390/mm/fault.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
arch/s390/mm/fault.c +4 -10
@@ -52,11 +52,11 @@extern int sysctl_userprocess_debug;#endif -#ifdef CONFIG_KPROBES -static inline int notify_page_fault (struct pt_regs *regs,long err) +static inline int notify_page_fault (struct pt_regs *regs) {int ret =0 ; +#ifdef CONFIG_KPROBES /* kprobe_running() needs smp_processor_id() */ if (!user_mode (regs)) {preempt_disable ();
@@ -64,15 +64,9 @@ ret =1 ; preempt_enable(); } - +#endif return ret; } -#else -static inline int notify_page_fault (struct pt_regs *regs,long err) -{ -return 0 ; -} -#endif /*
@@ -274,7 +268,7 @@int si_code;int fault; -if (notify_page_fault (regs, error_code)) +if (notify_page_fault (regs))return ; tsk = current;
PATCH 4/52 fault handler performance optimization.
In reply to Martin SchwidefskyFrom: Martin Schwidefsky <[email protected]>
Slim down the do_exception function to handle only the fast path of a fault and move the exceptional cases into a new function. That slightly increases the performance of the fault handling.
Build fix for !CONFIG_COMPAT by
Kamalesh Babulal <[email protected]>
---
arch/s390/mm/fault.c | 258 +++++++++++++++++++++++++-------------------------- 1 file changed, 129 insertions(+), 129 deletions(-)
arch/s390/mm/fault.c +129 -129
@@ -34,16 +34,15 @@#include <asm/pgtable.h> #include <asm/s390_ext.h> #include <asm/mmu_context.h> +#include <asm/compat.h> #include "../kernel/entry.h" #ifndef CONFIG_64BIT #define __FAIL_ADDR_MASK 0x7ffff000 -#define __FIXUP_MASK 0x7fffffff#define __SUBCODE_MASK 0x0200#define __PF_RES_FIELD 0ULL#else /* CONFIG_64BIT */ #define __FAIL_ADDR_MASK -4096L -#define __FIXUP_MASK ~0L#define __SUBCODE_MASK 0x0600#define __PF_RES_FIELD 0x8000000000000000ULL#endif /* CONFIG_64BIT */
@@ -52,6 +51,10 @@extern int sysctl_userprocess_debug;#endif +#define VM_FAULT_BADCONTEXT 0x010000 +#define VM_FAULT_BADMAP 0x020000 +#define VM_FAULT_BADACCESS 0x040000 +static inline int notify_page_fault (struct pt_regs *regs) {int ret =0 ;
@@ -122,18 +125,22 @@* Send SIGSEGV to task. This is an external routine * to keep the stack usage of do_page_fault small. */ -static void do_sigsegv (struct pt_regs *regs,unsigned long error_code, -int si_code,unsigned long address) +static noinline void do_sigsegv(struct pt_regs *regs, long int_code, +int si_code,unsigned long trans_exc_code) {struct siginfo si; +unsigned long address; + address = trans_exc_code & __FAIL_ADDR_MASK; + current->thread.prot_addr = address; + current->thread.trap_no = int_code;#if defined(CONFIG_SYSCTL ) || defined(CONFIG_PROCESS_DEBUG )#if defined(CONFIG_SYSCTL ) if (sysctl_userprocess_debug)#endif {printk ("User process fault: interruption code 0x%lX\n" , - error_code); + int_code);printk ("failing address: %lX\n" , address);show_regs (regs); }
@@ -144,14 +151,14 @@force_sig_info (SIGSEGV , &si, current); } -static void do_no_context (struct pt_regs *regs,unsigned long error_code, -unsigned long trans_exc_code) +static noinline void do_no_context(struct pt_regs *regs, long int_code, +unsigned long trans_exc_code) {const struct exception_table_entry *fixup;unsigned long address;/* Are we prepared to handle this kernel fault? */ - fixup =search_exception_tables (regs->psw.addr & __FIXUP_MASK); + fixup =search_exception_tables (regs->psw.addr &PSW_ADDR_INSN );if (fixup) { regs->psw.addr = fixup->fixup |PSW_ADDR_AMODE ;return ;
@@ -169,107 +176,127 @@printk (KERN_ALERT "Unable to handle kernel paging request" " at virtual user address %p\n" , (void *)address); -die ("Oops" , regs, error_code); +die ("Oops" , regs, int_code);do_exit (SIGKILL ); } -static void do_low_address (struct pt_regs *regs,unsigned long error_code, -unsigned long trans_exc_code) +static noinline void do_low_address(struct pt_regs *regs, long int_code, +unsigned long trans_exc_code) {/* Low-address protection hit in kernel mode means NULL pointer write access in kernel mode. */ if (regs->psw.mask &PSW_MASK_PSTATE ) {/* Low-address protection hit in user mode 'cannot happen'. */ -die ("Low-address protection" , regs, error_code); +die ("Low-address protection" , regs, int_code);do_exit (SIGKILL ); } -do_no_context (regs, error_code, trans_exc_code); +do_no_context (regs, int_code, trans_exc_code); } -static void do_sigbus (struct pt_regs *regs,unsigned long error_code, -unsigned long trans_exc_code) +static noinline void do_sigbus(struct pt_regs *regs, long int_code, +unsigned long trans_exc_code) {struct task_struct *tsk = current; -struct mm_struct *mm = tsk->mm; -up_read (&mm->mmap_sem);/* * Send a sigbus, regardless of whether we were in kernel * or user mode. */ tsk->thread.prot_addr = trans_exc_code & __FAIL_ADDR_MASK; - tsk->thread.trap_no = error_code; + tsk->thread.trap_no = int_code;force_sig (SIGBUS , tsk); - -/* Kernel mode? Handle exceptions or die */ -if (!(regs->psw.mask &PSW_MASK_PSTATE )) -do_no_context (regs, error_code, trans_exc_code); }#ifdef CONFIG_S390_EXEC_PROTECT -static int signal_return (struct mm_struct *mm,struct pt_regs *regs, -unsigned long address,unsigned long error_code) +static noinline int signal_return(struct pt_regs *regs, long int_code, +unsigned long trans_exc_code) {u16 instruction;int rc; -#ifdef CONFIG_COMPAT -int compat; -#endif -pagefault_disable (); rc =__get_user (instruction, (u16 __user *) regs->psw.addr); -pagefault_enable (); -if (rc) -return -EFAULT ; -up_read (&mm->mmap_sem); -clear_tsk_thread_flag (current,TIF_SINGLE_STEP ); -#ifdef CONFIG_COMPAT - compat =is_compat_task (); -if (compat && instruction ==0x0a77 ) -sys32_sigreturn (); -else if (compat && instruction ==0x0aad ) -sys32_rt_sigreturn (); - else -#endif -if (instruction ==0x0a77 ) -sys_sigreturn (); -else if (instruction ==0x0aad ) -sys_rt_sigreturn (); -else { - current->thread.prot_addr = address; - current->thread.trap_no = error_code; -do_sigsegv (regs, error_code,SEGV_MAPERR , address); - } +if (!rc && instruction ==0x0a77 ) { +clear_tsk_thread_flag (current,TIF_SINGLE_STEP ); +if (is_compat_task ()) +sys32_sigreturn (); +else +sys_sigreturn (); + }else if (!rc && instruction ==0x0aad ) { +clear_tsk_thread_flag (current,TIF_SINGLE_STEP ); +if (is_compat_task ()) +sys32_rt_sigreturn (); +else +sys_rt_sigreturn (); + }else +do_sigsegv (regs, int_code,SEGV_MAPERR , trans_exc_code);return 0 ; }#endif /* CONFIG_S390_EXEC_PROTECT */ +static noinline void do_fault_error(struct pt_regs *regs, long int_code, +unsigned long trans_exc_code,int fault) +{ +int si_code; + +switch (fault) { +case VM_FAULT_BADACCESS : +#ifdef CONFIG_S390_EXEC_PROTECT +if ((regs->psw.mask &PSW_MASK_ASC ) ==PSW_ASC_SECONDARY && + (trans_exc_code &3 ) ==0 ) { +signal_return (regs, int_code, trans_exc_code); +break ; + } +#endif /* CONFIG_S390_EXEC_PROTECT */ +case VM_FAULT_BADMAP : +/* Bad memory access. Check if it is kernel or user space. */ +if (regs->psw.mask &PSW_MASK_PSTATE ) { +/* User mode accesses just cause a SIGSEGV */ + si_code = (fault ==VM_FAULT_BADMAP ) ? +SEGV_MAPERR :SEGV_ACCERR ; +do_sigsegv (regs, int_code, si_code, trans_exc_code); +return ; + } +case VM_FAULT_BADCONTEXT : +do_no_context (regs, int_code, trans_exc_code); +break ; +default :/* fault & VM_FAULT_ERROR */ +if (fault &VM_FAULT_OOM ) +pagefault_out_of_memory (); +else if (fault &VM_FAULT_SIGBUS ) { +do_sigbus (regs, int_code, trans_exc_code); +/* Kernel mode? Handle exceptions or die */ +if (!(regs->psw.mask &PSW_MASK_PSTATE )) +do_no_context (regs, int_code, trans_exc_code); + }else +BUG (); +break ; + } +} +/* * This routine handles page faults. It determines the address, * and the problem, and then passes it off to one of the appropriate * routines. * -* error_code: +* interruption code (int_code): * 04 Protection -> Write-Protection (suprression) * 10 Segment translation -> Not present (nullification) * 11 Page translation -> Not present (nullification) * 3b Region third trans. -> Not present (nullification) */ -static inline void -do_exception (struct pt_regs *regs,unsigned long error_code,int write, -unsigned long trans_exc_code) +static inline int do_exception (struct pt_regs *regs,int write, +unsigned long trans_exc_code) {struct task_struct *tsk;struct mm_struct *mm;struct vm_area_struct *vma;unsigned long address; -int si_code;int fault;if (notify_page_fault (regs)) -return ; +return 0 ; tsk = current; mm = tsk->mm;
@@ -279,8 +306,9 @@* we are not in an interrupt and that there is a * user context. */ + fault =VM_FAULT_BADCONTEXT ;if (unlikely (!user_space_fault (trans_exc_code) ||in_atomic () || !mm)) - goto no_context; + goto out; address = trans_exc_code & __FAIL_ADDR_MASK;/*
@@ -292,41 +320,35 @@perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS ,1 ,0 , regs, address);down_read (&mm->mmap_sem); - si_code =SEGV_MAPERR ; + fault =VM_FAULT_BADMAP ; vma =find_vma (mm, address);if (!vma) - goto bad_area; + goto out_up; +if (unlikely (vma->vm_start > address)) { +if (!(vma->vm_flags &VM_GROWSDOWN )) + goto out_up; +if (expand_stack (vma, address)) + goto out_up; + } + +/* +* Ok, we have a good vm_area for this memory access, so +* we can handle it.. +*/ + fault =VM_FAULT_BADACCESS ;#ifdef CONFIG_S390_EXEC_PROTECT if (unlikely ((regs->psw.mask &PSW_MASK_ASC ) ==PSW_ASC_SECONDARY && (trans_exc_code &3 ) ==0 && !(vma->vm_flags &VM_EXEC ))) -if (!signal_return (mm, regs, address, error_code)) -/* -* signal_return() has done an up_read(&mm->mmap_sem) -* if it returns 0. -*/ -return ; + goto out_up;#endif - -if (vma->vm_start <= address) - goto good_area; -if (!(vma->vm_flags &VM_GROWSDOWN )) - goto bad_area; -if (expand_stack (vma, address)) - goto bad_area; -/* -* Ok, we have a good vm_area for this memory access, so -* we can handle it.. -*/ -good_area: - si_code =SEGV_ACCERR ;if (!write) {/* page not present, check vm flags */ if (!(vma->vm_flags & (VM_READ |VM_EXEC |VM_WRITE ))) - goto bad_area; + goto out_up; }else {if (!(vma->vm_flags &VM_WRITE )) - goto bad_area; + goto out_up; }if (is_vm_hugetlb_page (vma))
@@ -337,17 +359,9 @@* the fault. */ fault =handle_mm_fault (mm, vma, address, write ?FAULT_FLAG_WRITE :0 ); -if (unlikely (fault &VM_FAULT_ERROR )) { -if (fault &VM_FAULT_OOM ) { -up_read (&mm->mmap_sem); -pagefault_out_of_memory (); -return ; - }else if (fault &VM_FAULT_SIGBUS ) { -do_sigbus (regs, error_code, address); -return ; - } -BUG (); - } +if (unlikely (fault &VM_FAULT_ERROR )) + goto out_up; +if (fault &VM_FAULT_MAJOR ) { tsk->maj_flt++; perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, 0,
@@ -357,67 +371,55 @@perf_sw_event (PERF_COUNT_SW_PAGE_FAULTS_MIN ,1 ,0 , regs, address); } -up_read (&mm->mmap_sem);/* * The instruction that caused the program check will * be repeated. Don't signal single step via SIGTRAP. */ clear_tsk_thread_flag (tsk,TIF_SINGLE_STEP ); -return ; - -/* -* Something tried to access memory that isn't in our memory map.. -* Fix it, but check if it's kernel or user first.. -*/ -bad_area: + fault =0 ; +out_up:up_read (&mm->mmap_sem); - -/* User mode accesses just cause a SIGSEGV */ -if (regs->psw.mask &PSW_MASK_PSTATE ) { - tsk->thread.prot_addr = address; - tsk->thread.trap_no = error_code; -do_sigsegv (regs, error_code, si_code, address); -return ; - } - -no_context: -do_no_context (regs, error_code, trans_exc_code); +out: +return fault; } -void __kprobes do_protection_exception (struct pt_regs *regs, -long error_code) +void __kprobes do_protection_exception (struct pt_regs *regs,long int_code) {unsigned long trans_exc_code = S390_lowcore.trans_exc_code; +int fault;/* Protection exception is supressing, decrement psw address. */ - regs->psw.addr -= (error_code >>16 ); + regs->psw.addr -= (int_code >>16 );/* * Check for low-address protection. This needs to be treated * as a special case because the translation exception code * field is not guaranteed to contain valid data in this case. */ if (unlikely (!(trans_exc_code &4 ))) { -do_low_address (regs, error_code, trans_exc_code); +do_low_address (regs, int_code, trans_exc_code);return ; } -do_exception (regs,4 ,1 , trans_exc_code); + fault =do_exception (regs,1 , trans_exc_code); +if (unlikely (fault)) +do_fault_error (regs,4 , trans_exc_code, fault); } -void __kprobes do_dat_exception (struct pt_regs *regs,long error_code) +void __kprobes do_dat_exception (struct pt_regs *regs,long int_code) { -do_exception (regs, error_code &0xff ,0 , S390_lowcore.trans_exc_code); +unsigned long trans_exc_code = S390_lowcore.trans_exc_code; +int fault; + + fault =do_exception (regs,0 , trans_exc_code); +if (unlikely (fault)) +do_fault_error (regs, int_code &255 , trans_exc_code, fault); }#ifdef CONFIG_64BIT -void __kprobes do_asce_exception (struct pt_regs *regs,unsigned long error_code) +void __kprobes do_asce_exception (struct pt_regs *regs,long int_code) {unsigned long trans_exc_code = S390_lowcore.trans_exc_code; -struct mm_struct *mm; +struct mm_struct *mm = current->mm;struct vm_area_struct *vma; -unsigned long address; - - mm = current->mm; - address = trans_exc_code & __FAIL_ADDR_MASK;if (unlikely (!user_space_fault (trans_exc_code) ||in_atomic () || !mm)) goto no_context;
@@ -425,7 +427,7 @@local_irq_enable ();down_read (&mm->mmap_sem); - vma =find_vma (mm, address); + vma =find_vma (mm, trans_exc_code & __FAIL_ADDR_MASK);up_read (&mm->mmap_sem);if (vma) {
@@ -435,14 +437,12 @@/* User mode accesses just cause a SIGSEGV */ if (regs->psw.mask &PSW_MASK_PSTATE ) { - current->thread.prot_addr = address; - current->thread.trap_no = error_code; -do_sigsegv (regs, error_code,SEGV_MAPERR , address); +do_sigsegv (regs, int_code,SEGV_MAPERR , trans_exc_code);return ; } no_context: - do_no_context(regs, error_code, trans_exc_code); + do_no_context(regs, int_code, trans_exc_code); }#endif
@@ -507,7 +507,7 @@ : : "a" (&refbk), "m" (refbk) : "cc"); } -static void pfault_interrupt (__u16 error_code) +static void pfault_interrupt (__u16 int_code) {struct task_struct *tsk;__u16 subcode;
PATCH 5/52 fault handler access flags check.
In reply to Martin SchwidefskyFrom: Martin Schwidefsky <[email protected]>
Simplify the check of the vma->flags in do_exception for the different fault types.
---
arch/s390/mm/fault.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-)
arch/s390/mm/fault.c +13 -17
@@ -286,7 +286,7 @@* 11 Page translation -> Not present (nullification) * 3b Region third trans. -> Not present (nullification) */ -static inline int do_exception (struct pt_regs *regs,int write, +static inline int do_exception (struct pt_regs *regs,int access,unsigned long trans_exc_code) {struct task_struct *tsk;
@@ -337,19 +337,8 @@* we can handle it.. */ fault =VM_FAULT_BADACCESS ; -#ifdef CONFIG_S390_EXEC_PROTECT -if (unlikely ((regs->psw.mask &PSW_MASK_ASC ) ==PSW_ASC_SECONDARY && - (trans_exc_code &3 ) ==0 && !(vma->vm_flags &VM_EXEC ))) +if (unlikely (!(vma->vm_flags & access))) goto out_up; -#endif -if (!write) { -/* page not present, check vm flags */ -if (!(vma->vm_flags & (VM_READ |VM_EXEC |VM_WRITE ))) - goto out_up; - }else { -if (!(vma->vm_flags &VM_WRITE )) - goto out_up; - }if (is_vm_hugetlb_page (vma)) address &=HPAGE_MASK ;
@@ -358,7 +347,8 @@* make sure we exit gracefully rather than endlessly redo * the fault. */ - fault =handle_mm_fault (mm, vma, address, write ?FAULT_FLAG_WRITE :0 ); + fault =handle_mm_fault (mm, vma, address, + (access ==VM_WRITE ) ?FAULT_FLAG_WRITE :0 );if (unlikely (fault &VM_FAULT_ERROR )) goto out_up;
@@ -399,7 +389,7 @@do_low_address (regs, int_code, trans_exc_code);return ; } - fault =do_exception (regs,1 , trans_exc_code); + fault =do_exception (regs,VM_WRITE , trans_exc_code);if (unlikely (fault))do_fault_error (regs,4 , trans_exc_code, fault); }
@@ -407,9 +397,15 @@void __kprobes do_dat_exception (struct pt_regs *regs,long int_code) {unsigned long trans_exc_code = S390_lowcore.trans_exc_code; -int fault; +int access, fault; - fault =do_exception (regs,0 , trans_exc_code); + access =VM_READ |VM_EXEC |VM_WRITE ; +#ifdef CONFIG_S390_EXEC_PROTECT +if ((regs->psw.mask &PSW_MASK_ASC ) ==PSW_ASC_SECONDARY && + (trans_exc_code &3 ) ==0 ) + access =VM_EXEC ; +#endif + fault =do_exception (regs, access, trans_exc_code);if (unlikely (fault))do_fault_error (regs, int_code &255 , trans_exc_code, fault); }
PATCH 6/52 Use do_exception() in pagetable walk usercopy functions.
In reply to Martin SchwidefskyFrom: Gerald Schaefer <[email protected]>
The pagetable walk usercopy functions have used a modified copy of the do_exception() function for fault handling. This lead to inconsistencies with recent changes to do_exception(), e.g. performance counters. This patch changes the pagetable walk usercopy code to call do_exception() directly, eliminating the redundancy. A new parameter is added to do_exception() to specify the fault address.
---
arch/s390/include/asm/uaccess.h | 2 arch/s390/lib/uaccess_pt.c | 147 +++++++++++++--------------------------- arch/s390/mm/fault.c | 23 ++++++ 3 files changed, 76 insertions(+), 96 deletions(-)
arch/s390/include/asm/uaccess.h +2 -0
@@ -93,6 +93,8 @@extern struct uaccess_ops uaccess_mvcos_switch;extern struct uaccess_ops uaccess_pt; +extern int __handle_fault (unsigned long ,unsigned long ,int ); +static inline int __put_user_fn (size_t size,void __user *ptr,void *x) { size = uaccess.copy_to_user_small (size, ptr, x);
arch/s390/lib/uaccess_pt.c +51 -96
234 lines not on this page · raw message
arch/s390/mm/fault.c +23 -0
@@ -442,6 +442,29 @@ }#endif +int __handle_fault (unsigned long uaddr,unsigned long int_code,int write_user) +{ +struct pt_regs regs; +int access, fault; + + regs.psw.mask = psw_kernel_bits; +if (!irqs_disabled ()) + regs.psw.mask |=PSW_MASK_IO |PSW_MASK_EXT ; + regs.psw.addr = (unsigned long )__builtin_return_address (0 ); + regs.psw.addr |=PSW_ADDR_AMODE ; + uaddr &=PAGE_MASK ; + access = write_user ?VM_WRITE :VM_READ ; + fault =do_exception (®s, access, uaddr |2 ); +if (unlikely (fault)) { +if (fault &VM_FAULT_OOM ) { +pagefault_out_of_memory (); + fault =0 ; + }else if (fault &VM_FAULT_SIGBUS ) +do_sigbus (®s, int_code, uaddr); + } +return fault ? -EFAULT :0 ; +} +#ifdef CONFIG_PFAULT /* * 'pfault' pseudo page faults routines.
PATCH 7/52 Improve code generated by atomic operations.
In reply to Martin SchwidefskyFrom: Martin Schwidefsky <[email protected]>
Git commit ea435467500612636f8f4fb639ff6e76b2496e4b changed the definition of atomic_t and atomic64_t for s390 by adding the volatile modifier to the counter field. This has an unfortunate side effect with newer versions of the gcc. The typeof operator now picks up the volatile modifier from the expression. This causes the compiler to think that it has to store the two temporary variable old_val and new_val in the __CS_LOOP for the different atomic operations to the stack as the variables are now volatile. Both stores are superfluous.
The hack to replace typeof(ptr->counter) with int in __CS_LOOP and and long long in __CSG_LOOP avoids the two stores. A better solution would be to drop the volatile from the counter field of the atomic_t and atomic64_t definition. But that is a touchy subject ..
---
arch/s390/include/asm/atomic.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/s390/include/asm/atomic.h +4 -4
@@ -21,7 +21,7 @@#if __GNUC__ >3 || (__GNUC__ ==3 && __GNUC_MINOR__ >2 )#define __CS_LOOP (ptr, op_val, op_string) ({ \ - typeof(ptr->counter) old_val, new_val; \ + int old_val, new_val; \ asm volatile( \ " l %0,%2\n" \ "0: lr %1,%0\n" \
@@ -38,7 +38,7 @@#else /* __GNUC__ */ #define __CS_LOOP (ptr, op_val, op_string) ({ \ - typeof(ptr->counter) old_val, new_val; \ + int old_val, new_val; \ asm volatile( \ " l %0,0(%3)\n" \ "0: lr %1,%0\n" \
@@ -143,7 +143,7 @@#if __GNUC__ >3 || (__GNUC__ ==3 && __GNUC_MINOR__ >2 )#define __CSG_LOOP (ptr, op_val, op_string) ({ \ - typeof(ptr->counter) old_val, new_val; \ + long long old_val, new_val; \ asm volatile( \ " lg %0,%2\n" \ "0: lgr %1,%0\n" \
@@ -160,7 +160,7 @@#else /* __GNUC__ */ #define __CSG_LOOP (ptr, op_val, op_string) ({ \ - typeof(ptr->counter) old_val, new_val; \ + long long old_val, new_val; \ asm volatile( \ " lg %0,0(%3)\n" \ "0: lgr %1,%0\n" \
PATCH 8/52 dasd: support DIAG access for read-only devices
In reply to Martin SchwidefskyFrom: Stefan Weinhuber <[email protected]>
When a DASD device is used with the DIAG discipline, the DIAG initialization will indicate success or error with a respective return code. So far we have interpreted a return code of 4 as error, but it actually means that the initialization was successful, but the device is read-only. To allow read-only devices to be used with DIAG we need to accept a return code of 4 as success.
Re-initialization of the DIAG access is also part of the DIAG error recovery. If we find that the access mode of a device has been changed from writable to read-only while the device was in use, we print an error message.
---
drivers/s390/block/dasd_diag.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/s390/block/dasd_diag.c +16 -3
@@ -145,6 +145,15 @@mdsk_term_io (device); rc =mdsk_init_io (device, device->block->bp_block,0 ,NULL ); +if (rc ==4 ) { +if (!(device->features &DASD_FEATURE_READONLY )) { +dev_warn (&device->cdev->dev, +"The access mode of a DIAG device changed" +" to read-only" ); + device->features |=DASD_FEATURE_READONLY ; + } + rc =0 ; + }if (rc)dev_warn (&device->cdev->dev,"DIAG ERP failed with " "rc=%d\n" , rc);
@@ -433,16 +442,20 @@for (sb =512 ; sb < bsize; sb = sb <<1 ) block->s2b_shift++; rc =mdsk_init_io (device, block->bp_block,0 ,NULL ); -if (rc) { +if (rc && (rc !=4 )) {dev_warn (&device->cdev->dev,"DIAG initialization " "failed with rc=%d\n" , rc); rc = -EIO ; }else { +if (rc ==4 ) + device->features |=DASD_FEATURE_READONLY ;dev_info (&device->cdev->dev, -"New DASD with %ld byte/block, total size %ld KB\n" , +"New DASD with %ld byte/block, total size %ld KB%s\n" , (unsigned long ) block->bp_block, (unsigned long ) (block->blocks << - block->s2b_shift) >>1 ); + block->s2b_shift) >>1 , + (rc ==4 ) ?", read-only device" :"" ); + rc =0 ; } out_label:free_page ((long ) label);
PATCH 9/52 cmm: free pages on hibernate.
In reply to Martin SchwidefskyFrom: Martin Schwidefsky <[email protected]>
The pages allocated by the cmm memory balloon should be freed before the hibernation image is created. Otherwise the memory reserved by the balloon gets written to the swap device but there is no content in these pages that need to be preserved.
---
arch/s390/mm/cmm.c | 61 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 50 insertions(+), 11 deletions(-)
arch/s390/mm/cmm.c +50 -11
@@ -18,6 +18,7 @@#include <linux/swap.h> #include <linux/kthread.h> #include <linux/oom.h> +#include <linux/suspend.h> #include <asm/pgalloc.h> #include <asm/uaccess.h>
@@ -44,6 +45,7 @@static volatile long cmm_timed_pages_target;static long cmm_timeout_pages;static long cmm_timeout_seconds; +static int cmm_suspended;static struct cmm_page_array *cmm_page_list;static struct cmm_page_array *cmm_timed_page_list;
@@ -147,9 +149,9 @@while (1 ) { rc =wait_event_interruptible (cmm_thread_wait, - (cmm_pages != cmm_pages_target || - cmm_timed_pages != cmm_timed_pages_target || -kthread_should_stop ())); + (!cmm_suspended && (cmm_pages != cmm_pages_target || + cmm_timed_pages != cmm_timed_pages_target)) || +kthread_should_stop ());if (kthread_should_stop () || rc == -ERESTARTSYS ) { cmm_pages_target = cmm_pages; cmm_timed_pages_target = cmm_timed_pages;
@@ -411,6 +413,38 @@static struct ctl_table_header *cmm_sysctl_header; +static int cmm_suspend (void ) +{ + cmm_suspended =1 ; +cmm_free_pages (cmm_pages, &cmm_pages, &cmm_page_list); +cmm_free_pages (cmm_timed_pages, &cmm_timed_pages, &cmm_timed_page_list); +return 0 ; +} + +static int cmm_resume (void ) +{ + cmm_suspended =0 ; +cmm_kick_thread (); +return 0 ; +} + +static int cmm_power_event (struct notifier_block *this, +unsigned long event,void *ptr) +{ +switch (event) { +case PM_POST_HIBERNATION : +return cmm_resume (); +case PM_HIBERNATION_PREPARE : +return cmm_suspend (); +default : +return NOTIFY_DONE ; + } +} + +static struct notifier_block cmm_power_notifier = { + .notifier_call = cmm_power_event, +}; +static int cmm_init (void ) {
@@ -419,7 +453,7 @@#ifdef CONFIG_CMM_PROC cmm_sysctl_header =register_sysctl_table (cmm_dir_table);if (!cmm_sysctl_header) - goto out; + goto out_sysctl;#endif #ifdef CONFIG_CMM_IUCV rc =smsg_register_callback (SMSG_PREFIX , cmm_smsg_target);
@@ -429,17 +463,21 @@ rc =register_oom_notifier (&cmm_oom_nb);if (rc <0 ) goto out_oom_notify; + rc =register_pm_notifier (&cmm_power_notifier); +if (rc) + goto out_pm;init_waitqueue_head (&cmm_thread_wait);init_timer (&cmm_timer); cmm_thread_ptr =kthread_run (cmm_thread,NULL ,"cmmthread" ); rc =IS_ERR (cmm_thread_ptr) ?PTR_ERR (cmm_thread_ptr) :0 ; -if (!rc) - goto out; -/* -* kthread_create failed. undo all the stuff from above again. -*/ -unregister_oom_notifier (&cmm_oom_nb); +if (rc) + goto out_kthread; +return 0 ; +out_kthread: +unregister_pm_notifier (&cmm_power_notifier); +out_pm: +unregister_oom_notifier (&cmm_oom_nb); out_oom_notify: #ifdef CONFIG_CMM_IUCVsmsg_unregister_callback (SMSG_PREFIX ,cmm_smsg_target );
@@ -447,8 +485,8 @@#endif #ifdef CONFIG_CMM_PROC unregister_sysctl_table (cmm_sysctl_header); +out_sysctl:#endif -out:return rc; }
@@ -456,6 +494,7 @@cmm_exit (void) {kthread_stop (cmm_thread_ptr); +unregister_pm_notifier (&cmm_power_notifier);unregister_oom_notifier (&cmm_oom_nb);cmm_free_pages (cmm_pages, &cmm_pages, &cmm_page_list);cmm_free_pages (cmm_timed_pages, &cmm_timed_pages, &cmm_timed_page_list);
PATCH 10/52 smp: remove unused typedef and defines
In reply to Martin SchwidefskyFrom: Heiko Carstens <[email protected]>
Remove unused typedef, defines, update copyright, remove unneeded includes, remove unneeded ifdefs.
---
arch/s390/include/asm/smp.h | 54 ++++++++------------------------------------ 1 file changed, 10 insertions(+), 44 deletions(-)
arch/s390/include/asm/smp.h +10 -44
@@ -1,57 +1,22 @@/* -* include/asm-s390/smp.h -* -* S390 version -* Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation -* Author(s): Denis Joseph Barrow ([email protected],[email protected]), -* Martin Schwidefsky ([email protected]) -* Heiko Carstens ([email protected]) +* Copyright IBM Corp. 1999,2009 +* Author(s): Denis Joseph Barrow, +* Martin Schwidefsky <[email protected]>, +* Heiko Carstens <[email protected]>, */ #ifndef __ASM_SMP_H#define __ASM_SMP_H -#include <linux/threads.h> -#include <linux/cpumask.h> -#include <linux/bitops.h> +#ifdef CONFIG_SMP -#if defined(__KERNEL__) && defined(CONFIG_SMP ) && !defined(__ASSEMBLY__) - -#include <asm/lowcore.h> -#include <asm/sigp.h> -#include <asm/ptrace.h> #include <asm/system.h> - -/* -s390 specific smp.c headers -*/ -typedef struct -{ -int intresting; -sigp_ccode ccode; -__u32 status; -__u16 cpu; -}sigp_info ; +#include <asm/sigp.h> extern void machine_restart_smp (char *);extern void machine_halt_smp (void );extern void machine_power_off_smp (void ); -#define NO_PROC_ID 0xFF/* No processor magic marker */ - -/* -* This magic constant controls our willingness to transfer -* a process across CPUs. Such a transfer incurs misses on the L1 -* cache, and on a P6 or P5 with multiple L2 caches L2 hits. My -* gut feeling is this will vary by board in value. For a board -* with separate L2 cache it probably depends also on the RSS, and -* for a board with shared L2 cache it ought to decay fast as other -* processes are run. -*/ - -#define PROC_CHANGE_PENALTY 20/* Schedule penalty */ -#define raw_smp_processor_id () (S390_lowcore.cpu_nr) -#define cpu_logical_map (cpu) (cpu)extern int __cpu_disable (void );extern void __cpu_die (unsigned int cpu);
@@ -64,7 +29,9 @@extern void arch_send_call_function_single_ipi (int cpu);extern void arch_send_call_function_ipi_mask (const struct cpumask *mask); -#endif +extern union save_area *zfcpdump_save_areas[NR_CPUS +1 ]; + +#endif /* CONFIG_SMP */ #ifdef CONFIG_HOTPLUG_CPU extern int smp_rescan_cpus (void );
@@ -72,5 +39,4 @@static inline int smp_rescan_cpus (void ) {return 0 ; }#endif -extern union save_area *zfcpdump_save_areas[NR_CPUS +1 ]; -#endif +#endif /* __ASM_SMP_H */
PATCH 11/52 dasd: remove dead code
In reply to Martin SchwidefskyFrom: Christian Borntraeger <[email protected]>
the todclk.h header file is dead code. Remove it.
---
arch/s390/include/asm/todclk.h | 23 ----------------------- drivers/s390/block/dasd.c | 1 - drivers/s390/block/dasd_3990_erp.c | 1 - drivers/s390/block/dasd_diag.c | 1 - drivers/s390/block/dasd_eckd.c | 1 - drivers/s390/block/dasd_fba.c | 1 - 6 files changed, 28 deletions(-)
arch/s390/include/asm/todclk.h deleted +0 -23
@@ -1,23 +0,0 @@ -/* -* File...........: linux/include/asm/todclk.h -* Author(s)......: Holger Smolinski <[email protected]> -* Bugreports.to..: <[email protected]> -* (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000 -* -* History of changes (starts July 2000) -*/ - -#ifndef __ASM_TODCLK_H -#define __ASM_TODCLK_H - -#ifdef __KERNEL__ - -#define TOD_uSEC (0x1000ULL) -#define TOD_mSEC (1000 * TOD_uSEC) -#define TOD_SEC (1000 * TOD_mSEC) -#define TOD_MIN (60 * TOD_SEC) -#define TOD_HOUR (60 * TOD_MIN) - -#endif - -#endif
drivers/s390/block/dasd_3990_erp.c +0 -1
@@ -12,7 +12,6 @@#include <linux/timer.h> #include <linux/slab.h> #include <asm/idals.h> -#include <asm/todclk.h> #define PRINTK_HEADER "dasd_erp(3990): "
drivers/s390/block/dasd.c +0 -1
@@ -24,7 +24,6 @@#include <asm/ccwdev.h> #include <asm/ebcdic.h> #include <asm/idals.h> -#include <asm/todclk.h> #include <asm/itcw.h> /* This is ugly... */
drivers/s390/block/dasd_diag.c +0 -1
@@ -24,7 +24,6 @@#include <asm/ebcdic.h> #include <asm/io.h> #include <asm/s390_ext.h> -#include <asm/todclk.h> #include <asm/vtoc.h> #include <asm/diag.h>
drivers/s390/block/dasd_eckd.c +0 -1
@@ -24,7 +24,6 @@#include <asm/idals.h> #include <asm/ebcdic.h> #include <asm/io.h> -#include <asm/todclk.h> #include <asm/uaccess.h> #include <asm/cio.h> #include <asm/ccwdev.h>
drivers/s390/block/dasd_fba.c +0 -1
@@ -20,7 +20,6 @@#include <asm/idals.h> #include <asm/ebcdic.h> #include <asm/io.h> -#include <asm/todclk.h> #include <asm/ccwdev.h> #include "dasd_int.h"
PATCH 12/52 use generic termbits.h header file
In reply to Martin SchwidefskyFrom: Christian Borntraeger <[email protected]>
arch/s390/include/asm/termbits.h +3 -203
@@ -1,206 +1,6 @@ -/* -* include/asm-s390/termbits.h -* -* S390 version -* -* Derived from "include/asm-i386/termbits.h" -*/ +#ifndef _ASM_S390_TERMBITS_H +#define _ASM_S390_TERMBITS_H -#ifndef __ARCH_S390_TERMBITS_H__ -#define __ARCH_S390_TERMBITS_H__ - -#include <linux/posix_types.h> - -typedef unsigned char cc_t ; -typedef unsigned int speed_t ; -typedef unsigned int tcflag_t ; - -#define NCCS 19 -struct termios { -tcflag_t c_iflag;/* input mode flags */ -tcflag_t c_oflag;/* output mode flags */ -tcflag_t c_cflag;/* control mode flags */ -tcflag_t c_lflag;/* local mode flags */ -cc_t c_line;/* line discipline */ -cc_t c_cc[NCCS ];/* control characters */ -}; - -struct termios2 { -tcflag_t c_iflag;/* input mode flags */ -tcflag_t c_oflag;/* output mode flags */ -tcflag_t c_cflag;/* control mode flags */ -tcflag_t c_lflag;/* local mode flags */ -cc_t c_line;/* line discipline */ -cc_t c_cc[NCCS ];/* control characters */ -speed_t c_ispeed;/* input speed */ -speed_t c_ospeed;/* output speed */ -}; - -struct ktermios { -tcflag_t c_iflag;/* input mode flags */ -tcflag_t c_oflag;/* output mode flags */ -tcflag_t c_cflag;/* control mode flags */ -tcflag_t c_lflag;/* local mode flags */ -cc_t c_line;/* line discipline */ -cc_t c_cc[NCCS ];/* control characters */ -speed_t c_ispeed;/* input speed */ -speed_t c_ospeed;/* output speed */ -}; - -/* c_cc characters */ -#define VINTR 0 -#define VQUIT 1 -#define VERASE 2 -#define VKILL 3 -#define VEOF 4 -#define VTIME 5 -#define VMIN 6 -#define VSWTC 7 -#define VSTART 8 -#define VSTOP 9 -#define VSUSP 10 -#define VEOL 11 -#define VREPRINT 12 -#define VDISCARD 13 -#define VWERASE 14 -#define VLNEXT 15 -#define VEOL2 16 - -/* c_iflag bits */ -#define IGNBRK 0000001 -#define BRKINT 0000002 -#define IGNPAR 0000004 -#define PARMRK 0000010 -#define INPCK 0000020 -#define ISTRIP 0000040 -#define INLCR 0000100 -#define IGNCR 0000200 -#define ICRNL 0000400 -#define IUCLC 0001000 -#define IXON 0002000 -#define IXANY 0004000 -#define IXOFF 0010000 -#define IMAXBEL 0020000 -#define IUTF8 0040000 - -/* c_oflag bits */ -#define OPOST 0000001 -#define OLCUC 0000002 -#define ONLCR 0000004 -#define OCRNL 0000010 -#define ONOCR 0000020 -#define ONLRET 0000040 -#define OFILL 0000100 -#define OFDEL 0000200 -#define NLDLY 0000400 -#define NL0 0000000 -#define NL1 0000400 -#define CRDLY 0003000 -#define CR0 0000000 -#define CR1 0001000 -#define CR2 0002000 -#define CR3 0003000 -#define TABDLY 0014000 -#define TAB0 0000000 -#define TAB1 0004000 -#define TAB2 0010000 -#define TAB3 0014000 -#define XTABS 0014000 -#define BSDLY 0020000 -#define BS0 0000000 -#define BS1 0020000 -#define VTDLY 0040000 -#define VT0 0000000 -#define VT1 0040000 -#define FFDLY 0100000 -#define FF0 0000000 -#define FF1 0100000 - -/* c_cflag bit meaning */ -#define CBAUD 0010017 -#define B0 0000000/* hang up */ -#define B50 0000001 -#define B75 0000002 -#define B110 0000003 -#define B134 0000004 -#define B150 0000005 -#define B200 0000006 -#define B300 0000007 -#define B600 0000010 -#define B1200 0000011 -#define B1800 0000012 -#define B2400 0000013 -#define B4800 0000014 -#define B9600 0000015 -#define B19200 0000016 -#define B38400 0000017 -#define EXTA B19200 -#define EXTB B38400 -#define CSIZE 0000060 -#define CS5 0000000 -#define CS6 0000020 -#define CS7 0000040 -#define CS8 0000060 -#define CSTOPB 0000100 -#define CREAD 0000200 -#define PARENB 0000400 -#define PARODD 0001000 -#define HUPCL 0002000 -#define CLOCAL 0004000 -#define CBAUDEX 0010000 -#define BOTHER 0010000 -#define B57600 0010001 -#define B115200 0010002 -#define B230400 0010003 -#define B460800 0010004 -#define B500000 0010005 -#define B576000 0010006 -#define B921600 0010007 -#define B1000000 0010010 -#define B1152000 0010011 -#define B1500000 0010012 -#define B2000000 0010013 -#define B2500000 0010014 -#define B3000000 0010015 -#define B3500000 0010016 -#define B4000000 0010017 -#define CIBAUD 002003600000/* input baud rate */ -#define CMSPAR 010000000000/* mark or space (stick) parity */ -#define CRTSCTS 020000000000/* flow control */ - -#define IBSHIFT 16/* Shift from CBAUD to CIBAUD */ - -/* c_lflag bits */ -#define ISIG 0000001 -#define ICANON 0000002 -#define XCASE 0000004 -#define ECHO 0000010 -#define ECHOE 0000020 -#define ECHOK 0000040 -#define ECHONL 0000100 -#define NOFLSH 0000200 -#define TOSTOP 0000400 -#define ECHOCTL 0001000 -#define ECHOPRT 0002000 -#define ECHOKE 0004000 -#define FLUSHO 0010000 -#define PENDIN 0040000 -#define IEXTEN 0100000 - -/* tcflow() and TCXONC use these */ -#define TCOOFF 0 -#define TCOON 1 -#define TCIOFF 2 -#define TCION 3 - -/* tcflush() and TCFLSH use these */ -#define TCIFLUSH 0 -#define TCOFLUSH 1 -#define TCIOFLUSH 2 - -/* tcsetattr uses these */ -#define TCSANOW 0 -#define TCSADRAIN 1 -#define TCSAFLUSH 2 +#include <asm-generic/termbits.h> #endif
PATCH 13/52 use generic sockios.h header file
In reply to Martin SchwidefskyFrom: Christian Borntraeger <[email protected]>
arch/s390/include/asm/sockios.h +3 -18
@@ -1,21 +1,6 @@ -/* -* include/asm-s390/sockios.h -* -* S390 version -* -* Derived from "include/asm-i386/sockios.h" -*/ +#ifndef _ASM_S390_SOCKIOS_H +#define _ASM_S390_SOCKIOS_H -#ifndef __ARCH_S390_SOCKIOS__ -#define __ARCH_S390_SOCKIOS__ - -/* Socket-level I/O control calls. */ -#define FIOSETOWN 0x8901 -#define SIOCSPGRP 0x8902 -#define FIOGETOWN 0x8903 -#define SIOCGPGRP 0x8904 -#define SIOCATMARK 0x8905 -#define SIOCGSTAMP 0x8906/* Get stamp (timeval) */ -#define SIOCGSTAMPNS 0x8907/* Get stamp (timespec) */ +#include <asm-generic/sockios.h> #endif
PATCH 14/52 MAINTAINERS: Add s390 drivers block
In reply to Martin SchwidefskyFrom: Joe Perches <[email protected]>
There are currently 4 directories in drivers/s390
(block, char, cio, kvm) without maintainers.
Add drivers/s390/ to the s390 kvm section.
Add the rest to the default s390 section.
Add a W: link for drivers/s390/crypto/
---
MAINTAINERS | 3 +++ 1 file changed, 3 insertions(+)
MAINTAINERS +3 -0
@@ -3063,6 +3063,7 @@ F: Documentation/s390/kvm.txt F: arch/s390/include/asm/kvm* F: arch/s390/kvm/ +F: drivers/s390/kvm/ KEXEC M: Eric Biederman <[email protected]>
@@ -4471,6 +4472,7 @@ W: http://www.ibm.com/developerworks/linux/linux390/ S: Supported F: arch/s390/ +F: drivers/s390/ S390 NETWORK DRIVERS M: Ursula Braun <[email protected]>
@@ -4486,6 +4488,7 @@ M: Ralph Wuerthner <[email protected]> M: [email protected] L: [email protected] +W: http://www.ibm.com/developerworks/linux/linux390/ S: Supported F: drivers/s390/crypto/
PATCH 15/52 zcrypt: initialize ap_messages for cex3 exploitation
In reply to Martin SchwidefskyFrom: Felix Beck <[email protected]>
AP messages need to be initialized, before they will be used. Values will be zeroized. This will be needed later when introducing support for the special commands.
---
drivers/s390/crypto/ap_bus.h | 11 +++++++++++ drivers/s390/crypto/zcrypt_cex2a.c | 2 ++ drivers/s390/crypto/zcrypt_pcica.c | 2 ++ drivers/s390/crypto/zcrypt_pcicc.c | 2 ++ drivers/s390/crypto/zcrypt_pcixcc.c | 5 +++++ 5 files changed, 22 insertions(+)
drivers/s390/crypto/ap_bus.h +11 -0
@@ -167,6 +167,17 @@ .dev_type=(dt), \ .match_flags=AP_DEVICE_ID_MATCH_DEVICE_TYPE , +/** +* ap_init_message() - Initialize ap_message. +* Initialize a message before using. Otherwise this might result in +* unexpected behaviour. +*/ +extern inline void ap_init_message(struct ap_message *ap_msg) +{ + ap_msg->psmid =0 ; + ap_msg->length =0 ; +} +/* * Note: don't use ap_send/ap_recv after using ap_queue_message * for the first time. Otherwise the ap message queue will get
drivers/s390/crypto/zcrypt_cex2a.c +2 -0
@@ -298,6 +298,7 @@struct completion work;int rc; +ap_init_message (&ap_msg); ap_msg.message =kmalloc (CEX2A_MAX_MESSAGE_SIZE ,GFP_KERNEL );if (!ap_msg.message)return -ENOMEM ;
@@ -335,6 +336,7 @@struct completion work;int rc; +ap_init_message (&ap_msg); ap_msg.message =kmalloc (CEX2A_MAX_MESSAGE_SIZE ,GFP_KERNEL );if (!ap_msg.message)return -ENOMEM ;
drivers/s390/crypto/zcrypt_pcica.c +2 -0
@@ -281,6 +281,7 @@struct completion work;int rc; +ap_init_message (&ap_msg); ap_msg.message =kmalloc (PCICA_MAX_MESSAGE_SIZE ,GFP_KERNEL );if (!ap_msg.message)return -ENOMEM ;
@@ -318,6 +319,7 @@struct completion work;int rc; +ap_init_message (&ap_msg); ap_msg.message =kmalloc (PCICA_MAX_MESSAGE_SIZE ,GFP_KERNEL );if (!ap_msg.message)return -ENOMEM ;
drivers/s390/crypto/zcrypt_pcicc.c +2 -0
@@ -483,6 +483,7 @@struct completion work;int rc; +ap_init_message (&ap_msg); ap_msg.message = (void *)get_zeroed_page (GFP_KERNEL );if (!ap_msg.message)return -ENOMEM ;
@@ -521,6 +522,7 @@struct completion work;int rc; +ap_init_message (&ap_msg); ap_msg.message = (void *)get_zeroed_page (GFP_KERNEL );if (!ap_msg.message)return -ENOMEM ;
drivers/s390/crypto/zcrypt_pcixcc.c +5 -0
@@ -688,6 +688,7 @@ };int rc; +ap_init_message (&ap_msg); ap_msg.message = (void *)get_zeroed_page (GFP_KERNEL );if (!ap_msg.message)return -ENOMEM ;
@@ -727,6 +728,7 @@ };int rc; +ap_init_message (&ap_msg); ap_msg.message = (void *)get_zeroed_page (GFP_KERNEL );if (!ap_msg.message)return -ENOMEM ;
@@ -766,6 +768,7 @@ };int rc; +ap_init_message (&ap_msg); ap_msg.message =kmalloc (PCIXCC_MAX_XCRB_MESSAGE_SIZE ,GFP_KERNEL );if (!ap_msg.message)return -ENOMEM ;
@@ -805,6 +808,7 @@ };int rc; +ap_init_message (&ap_msg); ap_msg.message =kmalloc (PCIXCC_MAX_XCRB_MESSAGE_SIZE ,GFP_KERNEL );if (!ap_msg.message)return -ENOMEM ;
@@ -972,6 +976,7 @@ } __attribute__((packed)) *reply;int rc, i; +ap_init_message (&ap_msg); ap_msg.message = (void *)get_zeroed_page (GFP_KERNEL );if (!ap_msg.message)return -ENOMEM ;
PATCH 16/52 zcrypt: special command support for cex3 exploitation
In reply to Martin SchwidefskyFrom: Felix Beck <[email protected]>
Support for special command is implemented in the AP Bus in the NQAP function __ap_send. This is extended for a further parameter special. When set, the special bit, in GR0 will be set. Therefor the ap_message struct is extended for a further bit. Thus calling functions of __ap_send can use the special parameter in ap_message to give to __ap_send. Affected is in the first place ap_queue_message, which is called by the actual card driver. The second part of this support is that the card driver for the CEX3C needs to set this special bit, when an according CPRB is sent to the driver.
---
drivers/s390/crypto/ap_bus.c | 20 +++++++++++++++----- drivers/s390/crypto/ap_bus.h | 3 +++ drivers/s390/crypto/zcrypt_pcixcc.c | 5 +++++ 3 files changed, 23 insertions(+), 5 deletions(-)
drivers/s390/crypto/ap_bus.c +15 -5
@@ -282,6 +282,7 @@* @psmid: The program supplied message identifier * @msg: The message text * @length: The message length +* @special: Special Bit * * Returns AP queue status structure. * Condition code 1 on NQAP can't happen because the L bit is 1.
@@ -289,7 +290,8 @@* because a segment boundary was reached. The NQAP is repeated. */ static inline struct ap_queue_status -__ap_send (ap_qid_t qid,unsigned long long psmid,void *msg,size_t length) +__ap_send (ap_qid_t qid,unsigned long long psmid,void *msg,size_t length, +unsigned int special) {typedef struct {char _[length]; }msgblock ; register unsigned long reg0 asm ("0") = qid | 0x40000000UL;
@@ -299,6 +301,9 @@ register unsigned long reg4 asm ("4") = (unsigned int) (psmid >> 32); register unsigned long reg5 asm ("5") = (unsigned int) psmid; +if (special ==1 ) + reg0 |=0x400000UL ; + asmvolatile ("0: .long 0xb2ad0042\n" /* DQAP */ " brc 2,0b"
@@ -312,13 +317,15 @@ {struct ap_queue_status status; - status =__ap_send (qid, psmid, msg, length); + status =__ap_send (qid, psmid, msg, length,0 );switch (status.response_code) {case AP_RESPONSE_NORMAL :return 0 ;case AP_RESPONSE_Q_FULL :case AP_RESPONSE_RESET_IN_PROGRESS :return -EBUSY ; +case AP_RESPONSE_REQ_FAC_NOT_INST : +return -EINVAL ;default :/* Device is gone. */ return -ENODEV ; }
@@ -1008,7 +1015,7 @@ } status =__ap_send (ap_dev->qid,0x0102030405060708ULL , - msg,sizeof (msg)); + msg,sizeof (msg),0 );if (status.response_code !=AP_RESPONSE_NORMAL ) { rc = -ENODEV ; goto out_free;
@@ -1243,7 +1250,7 @@/* Start the next request on the queue. */ ap_msg = list_entry(ap_dev->requestq.next, struct ap_message, list); status =__ap_send (ap_dev->qid, ap_msg->psmid, - ap_msg->message, ap_msg->length); + ap_msg->message, ap_msg->length, ap_msg->special);switch (status.response_code) {case AP_RESPONSE_NORMAL :atomic_inc (&ap_poll_requests);
@@ -1261,6 +1268,7 @@ *flags |=2 ;break ;case AP_RESPONSE_MESSAGE_TOO_BIG : +case AP_RESPONSE_REQ_FAC_NOT_INST :return -EINVAL ;default :return -ENODEV ;
@@ -1302,7 +1310,8 @@if (list_empty (&ap_dev->requestq) && ap_dev->queue_count < ap_dev->queue_depth) { status =__ap_send (ap_dev->qid, ap_msg->psmid, - ap_msg->message, ap_msg->length); + ap_msg->message, ap_msg->length, + ap_msg->special);switch (status.response_code) {case AP_RESPONSE_NORMAL :list_add_tail (&ap_msg->list, &ap_dev->pendingq);
@@ -1317,6 +1326,7 @@ ap_dev->requestq_count++; ap_dev->total_request_count++;return -EBUSY ; +case AP_RESPONSE_REQ_FAC_NOT_INST :case AP_RESPONSE_MESSAGE_TOO_BIG : ap_dev->drv->receive (ap_dev, ap_msg,ERR_PTR (-EINVAL ));return -EINVAL ;
drivers/s390/crypto/ap_bus.h +3 -0
@@ -87,6 +87,7 @@#define AP_RESPONSE_INDEX_TOO_BIG 0x11#define AP_RESPONSE_NO_FIRST_PART 0x13#define AP_RESPONSE_MESSAGE_TOO_BIG 0x15 +#define AP_RESPONSE_REQ_FAC_NOT_INST 0x16/* * Known device types
@@ -161,6 +162,7 @@size_t length;/* Message length. */ void *private;/* ap driver private pointer. */ + unsigned int special:1; /* Used for special commands. */ };#define AP_DEVICE (dt) \
@@ -176,6 +178,7 @@ { ap_msg->psmid =0 ; ap_msg->length =0 ; + ap_msg->special =0 ; }/*
drivers/s390/crypto/zcrypt_pcixcc.c +5 -0
@@ -326,6 +326,11 @@ function_code = ((unsigned char *)&msg->cprbx) + msg->cprbx.cprb_len;memcpy (msg->hdr.function_code, function_code,sizeof (msg->hdr.function_code)); +if (memcmp (function_code,"US" ,2 ) ==0 ) + ap_msg->special =1 ; +else + ap_msg->special =0 ; +/* copy data block */ if (xcRB->request_data_length && copy_from_user(req_data, xcRB->request_data_address,
PATCH 17/52 zcrypt: add support for cex3 device types
In reply to Martin SchwidefskyFrom: Felix Beck <[email protected]>
This patch renames the CEX2C2 and CEX2A2 types to CEX3 device types.
---
drivers/s390/crypto/ap_bus.h | 4 ++-- drivers/s390/crypto/zcrypt_api.c | 9 +++++++-- drivers/s390/crypto/zcrypt_cex2a.c | 2 +- drivers/s390/crypto/zcrypt_pcixcc.c | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-)
drivers/s390/crypto/ap_bus.h +2 -2
@@ -97,8 +97,8 @@#define AP_DEVICE_TYPE_PCIXCC 5#define AP_DEVICE_TYPE_CEX2A 6#define AP_DEVICE_TYPE_CEX2C 7 -#define AP_DEVICE_TYPE_CEX2A2 8 -#define AP_DEVICE_TYPE_CEX2C2 9 +#define AP_DEVICE_TYPE_CEX3A 8 +#define AP_DEVICE_TYPE_CEX3C 9/* * AP reset flag states
drivers/s390/crypto/zcrypt_api.c +7 -2
@@ -1009,6 +1009,10 @@ zcrypt_count_type(ZCRYPT_CEX2C)); len +=sprintf (resp_buff + len,"CEX2A count: %d\n" ,zcrypt_count_type (ZCRYPT_CEX2A )); + len +=sprintf (resp_buff + len,"CEX3C count: %d\n" , +zcrypt_count_type (ZCRYPT_CEX3C )); + len +=sprintf (resp_buff + len,"CEX3A count: %d\n" , +zcrypt_count_type (ZCRYPT_CEX3A )); len +=sprintf (resp_buff + len,"requestq count: %d\n" ,zcrypt_requestq_count ()); len += sprintf(resp_buff + len, "pendingq count: %d\n",
@@ -1017,7 +1021,7 @@ atomic_read(&zcrypt_open_count));zcrypt_status_mask (workarea); len +=sprinthx ("Online devices: 1=PCICA 2=PCICC 3=PCIXCC(MCL2) " -"4=PCIXCC(MCL3) 5=CEX2C 6=CEX2A" , +"4=PCIXCC(MCL3) 5=CEX2C 6=CEX2A 7=CEX3C 8=CEX3A" , resp_buff+len, workarea,AP_DEVICES );zcrypt_qdepth_mask (workarea); len += sprinthx("Waiting work element counts",
@@ -1095,8 +1099,9 @@* '0' for no device, '1' for PCICA, '2' for PCICC, * '3' for PCIXCC_MCL2, '4' for PCIXCC_MCL3, * '5' for CEX2C and '6' for CEX2A' +* '7' for CEX3C and '8' for CEX3A */ -if (*ptr >='0' && *ptr <='6' ) +if (*ptr >='0' && *ptr <='8' ) j++;else if (*ptr =='d' || *ptr =='D' )zcrypt_disable_card (j++);
drivers/s390/crypto/zcrypt_cex2a.c +1 -1
@@ -49,7 +49,7 @@static struct ap_device_id zcrypt_cex2a_ids[] = { {AP_DEVICE (AP_DEVICE_TYPE_CEX2A ) }, - {AP_DEVICE (AP_DEVICE_TYPE_CEX2A2 ) }, + {AP_DEVICE (AP_DEVICE_TYPE_CEX3A ) }, {/* end of list */ }, };
drivers/s390/crypto/zcrypt_pcixcc.c +1 -1
@@ -72,7 +72,7 @@static struct ap_device_id zcrypt_pcixcc_ids[] = { {AP_DEVICE (AP_DEVICE_TYPE_PCIXCC ) }, {AP_DEVICE (AP_DEVICE_TYPE_CEX2C ) }, - {AP_DEVICE (AP_DEVICE_TYPE_CEX2C2 ) }, + {AP_DEVICE (AP_DEVICE_TYPE_CEX3C ) }, {/* end of list */ }, };
PATCH 18/52 zcrypt: use definitions for cex3
In reply to Martin SchwidefskyFrom: Felix Beck <[email protected]>
New definitions are added for CEX3 device types. They will be set in the according probe functions. CEX3 device types will be handled in the same modules as CEX2 device types. In the first step they are the same as CEX2 types, but they can be adjusted for further characteristics of CEX3 easily.
---
drivers/s390/crypto/zcrypt_api.h | 2 + drivers/s390/crypto/zcrypt_cex2a.c | 69 +++++++++++++++++++++++------------- drivers/s390/crypto/zcrypt_pcixcc.c | 22 +++++++++-- 3 files changed, 66 insertions(+), 27 deletions(-)
drivers/s390/crypto/zcrypt_api.h +2 -0
@@ -71,6 +71,8 @@#define ZCRYPT_PCIXCC_MCL3 4#define ZCRYPT_CEX2C 5#define ZCRYPT_CEX2A 6 +#define ZCRYPT_CEX3C 7 +#define ZCRYPT_CEX3A 8/** * Large random numbers are pulled in 4096 byte chunks from the crypto cards
drivers/s390/crypto/zcrypt_cex2a.c +45 -24
89 lines not on this page · raw message
drivers/s390/crypto/zcrypt_pcixcc.c +19 -3
@@ -43,10 +43,13 @@#define PCIXCC_MIN_MOD_SIZE 16/* 128 bits */ #define PCIXCC_MIN_MOD_SIZE_OLD 64/* 512 bits */ #define PCIXCC_MAX_MOD_SIZE 256/* 2048 bits */ +#define CEX3C_MIN_MOD_SIZE PCIXCC_MIN_MOD_SIZE +#define CEX3C_MAX_MOD_SIZE PCIXCC_MAX_MOD_SIZE#define PCIXCC_MCL2_SPEED_RATING 7870/* FIXME: needs finetuning */ #define PCIXCC_MCL3_SPEED_RATING 7870#define CEX2C_SPEED_RATING 8540 +#define CEX3C_SPEED_RATING 10000/* FIXME: needs finetuning */ #define PCIXCC_MAX_ICA_MESSAGE_SIZE 0x77c/* max size type6 v2 crt message */ #define PCIXCC_MAX_ICA_RESPONSE_SIZE 0x77c/* max size type86 v2 reply */
@@ -1026,14 +1029,15 @@static int zcrypt_pcixcc_probe (struct ap_device *ap_dev) {struct zcrypt_device *zdev; -int rc; +int rc =0 ; zdev =zcrypt_device_alloc (PCIXCC_MAX_RESPONSE_SIZE );if (!zdev)return -ENOMEM ; zdev->ap_dev = ap_dev; zdev->online =1 ; -if (ap_dev->device_type ==AP_DEVICE_TYPE_PCIXCC ) { +switch (ap_dev->device_type) { +case AP_DEVICE_TYPE_PCIXCC : rc =zcrypt_pcixcc_mcl (ap_dev);if (rc <0 ) {zcrypt_device_free (zdev);
@@ -1051,13 +1055,25 @@ zdev->min_mod_size =PCIXCC_MIN_MOD_SIZE ; zdev->max_mod_size =PCIXCC_MAX_MOD_SIZE ; } - }else { +break ; +case AP_DEVICE_TYPE_CEX2C : zdev->user_space_type =ZCRYPT_CEX2C ; zdev->type_string ="CEX2C" ; zdev->speed_rating =CEX2C_SPEED_RATING ; zdev->min_mod_size =PCIXCC_MIN_MOD_SIZE ; zdev->max_mod_size =PCIXCC_MAX_MOD_SIZE ; +break ; +case AP_DEVICE_TYPE_CEX3C : + zdev->user_space_type =ZCRYPT_CEX3C ; + zdev->type_string ="CEX3C" ; + zdev->speed_rating =CEX3C_SPEED_RATING ; + zdev->min_mod_size =CEX3C_MIN_MOD_SIZE ; + zdev->max_mod_size =CEX3C_MAX_MOD_SIZE ; +break ; +default : + goto out_free; } + rc =zcrypt_pcixcc_rng_supported (ap_dev);if (rc <0 ) {zcrypt_device_free (zdev);
PATCH 19/52 zcrypt: adjust speed rating between cex2 and pcixcc
In reply to Martin SchwidefskyFrom: Felix Beck <[email protected]>
Cards with lower speed rating are prefered. Thus change adjust the speed rating of cex2c adapters to be prefered before pcixcc, although they should not appear in the same machine anyway.
---
drivers/s390/crypto/zcrypt_pcixcc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/crypto/zcrypt_pcixcc.c +2 -2
@@ -46,9 +46,9 @@#define CEX3C_MIN_MOD_SIZE PCIXCC_MIN_MOD_SIZE#define CEX3C_MAX_MOD_SIZE PCIXCC_MAX_MOD_SIZE -#define PCIXCC_MCL2_SPEED_RATING 7870/* FIXME: needs finetuning */ +#define PCIXCC_MCL2_SPEED_RATING 7870#define PCIXCC_MCL3_SPEED_RATING 7870 -#define CEX2C_SPEED_RATING 8540 +#define CEX2C_SPEED_RATING 7000#define CEX3C_SPEED_RATING 10000/* FIXME: needs finetuning */ #define PCIXCC_MAX_ICA_MESSAGE_SIZE 0x77c/* max size type6 v2 crt message */
PATCH 20/52 zcrypt: adjust speed rating of cex3 adapters
In reply to Martin SchwidefskyFrom: Felix Beck <[email protected]>
Cex3 needs a lower speed rating. Otherwise cex2 adapters will be prefered.
---
drivers/s390/crypto/zcrypt_cex2a.c | 2 +- drivers/s390/crypto/zcrypt_pcixcc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/s390/crypto/zcrypt_cex2a.c +1 -1
@@ -43,7 +43,7 @@#define CEX3A_MAX_MOD_SIZE CEX2A_MAX_MOD_SIZE#define CEX2A_SPEED_RATING 970 -#define CEX3A_SPEED_RATING 1100 +#define CEX3A_SPEED_RATING 900/* Fixme: Needs finetuning */ #define CEX2A_MAX_MESSAGE_SIZE 0x390/* sizeof(struct type50_crb2_msg) */ #define CEX2A_MAX_RESPONSE_SIZE 0x110/* max outputdatalength + type80_hdr */
drivers/s390/crypto/zcrypt_pcixcc.c +1 -1
@@ -49,7 +49,7 @@#define PCIXCC_MCL2_SPEED_RATING 7870#define PCIXCC_MCL3_SPEED_RATING 7870#define CEX2C_SPEED_RATING 7000 -#define CEX3C_SPEED_RATING 10000/* FIXME: needs finetuning */ +#define CEX3C_SPEED_RATING 6500/* FIXME: needs finetuning */ #define PCIXCC_MAX_ICA_MESSAGE_SIZE 0x77c/* max size type6 v2 crt message */ #define PCIXCC_MAX_ICA_RESPONSE_SIZE 0x77c/* max size type86 v2 reply */
PATCH 21/52 dasd: enable prefix independent of pav support
In reply to Martin SchwidefskyFrom: Stefan Weinhuber <[email protected]>
The DASD device driver needs to explicitly enable the prefix command on the storage server, before it can be used. Originally we enabled this command along with others only if we wanted to support PAV. However, today we require this command for other features like High Performance FICON as well, so we need to always enable prefix.
---
drivers/s390/block/dasd_eckd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/s390/block/dasd_eckd.c +2 -2
@@ -1011,9 +1011,9 @@ } psf_ssc_data = (struct dasd_psf_ssc_data *)cqr->data; psf_ssc_data->order =PSF_ORDER_SSC ; - psf_ssc_data->suborder =0x40 ; + psf_ssc_data->suborder =0xc0 ;if (enable_pav) { - psf_ssc_data->suborder |=0x88 ; + psf_ssc_data->suborder |=0x08 ; psf_ssc_data->reserved[0 ] =0x88 ; } ccw = cqr->cpaddr;
PATCH 22/52 dasd: improve error recovery for internal I/O
In reply to Martin SchwidefskyFrom: Stefan Weinhuber <[email protected]>
Most of the error conditions reported by a FICON storage server indicate situations which can be recovered. Sometimes the host just needs to retry an I/O request, but sometimes the recovery is more complex and requires the device driver to wait, choose a different path, etc.
The DASD device driver has a fully featured error recovery for normal block layer I/O, but not for internal I/O request which are for example used during the device bring up.
This can lead to situations where the IPL of a system fails because DASD devices are not properly recognized.
This patch will extend the internal I/O handling to use the existing error recovery procedures.
---
drivers/s390/block/dasd.c | 207 +++++++++++++++++++++++++++---------- drivers/s390/block/dasd_3990_erp.c | 46 +++++--- drivers/s390/block/dasd_alias.c | 15 +- drivers/s390/block/dasd_eckd.c | 72 +++++++++--- drivers/s390/block/dasd_int.h | 3 drivers/s390/block/dasd_ioctl.c | 4 6 files changed, 253 insertions(+), 94 deletions(-)
drivers/s390/block/dasd_3990_erp.c +33 -13
@@ -69,8 +69,7 @@* processing until the started timer has expired or an related * interrupt was received. */ -static void -dasd_3990_erp_block_queue (struct dasd_ccw_req * erp,int expires) +static void dasd_3990_erp_block_queue (struct dasd_ccw_req *erp,int expires) {struct dasd_device *device = erp->startdev;
@@ -80,10 +79,13 @@ "blocking request queue for %is", expires/HZ);spin_lock_irqsave (get_ccwdev_lock (device->cdev), flags); - device->stopped |=DASD_STOPPED_PENDING ; +dasd_device_set_stop_bits (device,DASD_STOPPED_PENDING );spin_unlock_irqrestore (get_ccwdev_lock (device->cdev), flags); erp->status =DASD_CQR_FILLED ; -dasd_block_set_timer (device->block, expires); +if (erp->block) +dasd_block_set_timer (erp->block, expires); +else +dasd_device_set_timer (device, expires); }/*
@@ -242,9 +244,13 @@* DESCRIPTION * Setup ERP to do the ERP action 1 (see Reference manual). * Repeat the operation on a different channel path. -* If all alternate paths have been tried, the request is posted with a -* permanent error. -* Note: duplex handling is not implemented (yet). +* As deviation from the recommended recovery action, we reset the path mask +* after we have tried each path and go through all paths a second time. +* This will cover situations where only one path at a time is actually down, +* but all paths fail and recover just with the same sequence and timing as +* we try to use them (flapping links). +* If all alternate paths have been tried twice, the request is posted with +* a permanent error. * * PARAMETER * erp pointer to the current ERP
@@ -253,17 +259,25 @@* erp pointer to the ERP * */ -static struct dasd_ccw_req * -dasd_3990_erp_action_1 (struct dasd_ccw_req * erp) +static struct dasd_ccw_req *dasd_3990_erp_action_1_sec (struct dasd_ccw_req *erp) { + erp->function = dasd_3990_erp_action_1_sec; +dasd_3990_erp_alternate_path (erp); +return erp; +} +static struct dasd_ccw_req *dasd_3990_erp_action_1 (struct dasd_ccw_req *erp) +{ erp->function = dasd_3990_erp_action_1; -dasd_3990_erp_alternate_path (erp); - +if (erp->status ==DASD_CQR_FAILED ) { + erp->status =DASD_CQR_FILLED ; + erp->retries =10 ; + erp->lpm =LPM_ANYPATH ; + erp->function = dasd_3990_erp_action_1_sec; + }return erp; - -}/* end dasd_3990_erp_action_1 */ +}/* end dasd_3990_erp_action_1(b) */ /* * DASD_3990_ERP_ACTION_4
@@ -2294,6 +2308,7 @@return cqr; } + ccw = cqr->cpaddr;if (cqr->cpmode ==1 ) {/* make a shallow copy of the original tcw but set new tsb */ erp->cpmode =1 ;
@@ -2302,6 +2317,9 @@ tsb = (struct tsb *) &tcw[1 ]; *tcw = *((struct tcw *)cqr->cpaddr); tcw->tsb = (long )tsb; + }else if (ccw->cmd_code ==DASD_ECKD_CCW_PSF ) { +/* PSF cannot be chained from NOOP/TIC */ + erp->cpaddr = cqr->cpaddr; }else {/* initialize request with default TIC to current ERP/CQR */ ccw = erp->cpaddr;
@@ -2486,6 +2504,8 @@ erp =dasd_3990_erp_action_1 (erp); + }else if (erp->function == dasd_3990_erp_action_1_sec) { + erp =dasd_3990_erp_action_1_sec (erp); }else if (erp->function == dasd_3990_erp_action_5) {/* retries have not been successful */
drivers/s390/block/dasd_alias.c +8 -7
@@ -755,11 +755,11 @@ {/* If pos == device then device is already locked! */ if (pos == device) { - pos->stopped |=DASD_STOPPED_SU ; +dasd_device_set_stop_bits (pos,DASD_STOPPED_SU );return ; }spin_lock (get_ccwdev_lock (pos->cdev)); - pos->stopped |=DASD_STOPPED_SU ; +dasd_device_set_stop_bits (pos,DASD_STOPPED_SU );spin_unlock (get_ccwdev_lock (pos->cdev)); }
@@ -793,26 +793,26 @@list_for_each_entry (device, &lcu->active_devices, alias_list) {spin_lock_irqsave (get_ccwdev_lock (device->cdev), flags); - device->stopped &= ~DASD_STOPPED_SU ; +dasd_device_remove_stop_bits (device,DASD_STOPPED_SU );spin_unlock_irqrestore (get_ccwdev_lock (device->cdev), flags); }list_for_each_entry (device, &lcu->inactive_devices, alias_list) {spin_lock_irqsave (get_ccwdev_lock (device->cdev), flags); - device->stopped &= ~DASD_STOPPED_SU ; +dasd_device_remove_stop_bits (device,DASD_STOPPED_SU );spin_unlock_irqrestore (get_ccwdev_lock (device->cdev), flags); }list_for_each_entry (pavgroup, &lcu->grouplist, group) {list_for_each_entry (device, &pavgroup->baselist, alias_list) {spin_lock_irqsave (get_ccwdev_lock (device->cdev), flags); - device->stopped &= ~DASD_STOPPED_SU ; +dasd_device_remove_stop_bits (device,DASD_STOPPED_SU );spin_unlock_irqrestore (get_ccwdev_lock (device->cdev), flags); }list_for_each_entry (device, &pavgroup->aliaslist, alias_list) {spin_lock_irqsave (get_ccwdev_lock (device->cdev), flags); - device->stopped &= ~DASD_STOPPED_SU ; +dasd_device_remove_stop_bits (device,DASD_STOPPED_SU );spin_unlock_irqrestore (get_ccwdev_lock (device->cdev), flags); }
@@ -836,7 +836,8 @@/* 2. reset summary unit check */ spin_lock_irqsave (get_ccwdev_lock (device->cdev), flags); - device->stopped &= ~(DASD_STOPPED_SU |DASD_STOPPED_PENDING ); +dasd_device_remove_stop_bits (device, + (DASD_STOPPED_SU |DASD_STOPPED_PENDING ));spin_unlock_irqrestore (get_ccwdev_lock (device->cdev), flags);reset_summary_unit_check (lcu, device, suc_data->reason);
drivers/s390/block/dasd.c +152 -55
329 lines not on this page · raw message
drivers/s390/block/dasd_eckd.c +55 -17
163 lines not on this page · raw message
drivers/s390/block/dasd_int.h +3 -0
@@ -595,6 +595,9 @@int dasd_generic_read_dev_chars (struct dasd_device *,int ,void *,int );char *dasd_get_sense (struct irb *); +void dasd_device_set_stop_bits (struct dasd_device *,int ); +void dasd_device_remove_stop_bits (struct dasd_device *,int ); +/* externals in dasd_devmap.c */ extern int dasd_max_devindex;extern int dasd_probeonly;
drivers/s390/block/dasd_ioctl.c +2 -2
@@ -101,7 +101,7 @@pr_info ("%s: The DASD has been put in the quiesce " "state\n" ,dev_name (&base->cdev->dev));spin_lock_irqsave (get_ccwdev_lock (base->cdev), flags); - base->stopped |=DASD_STOPPED_QUIESCE ; +dasd_device_set_stop_bits (base,DASD_STOPPED_QUIESCE );spin_unlock_irqrestore (get_ccwdev_lock (base->cdev), flags);return 0 ; }
@@ -122,7 +122,7 @@pr_info ("%s: I/O operations have been resumed " "on the DASD\n" ,dev_name (&base->cdev->dev));spin_lock_irqsave (get_ccwdev_lock (base->cdev), flags); - base->stopped &= ~DASD_STOPPED_QUIESCE ; +dasd_device_remove_stop_bits (base,DASD_STOPPED_QUIESCE );spin_unlock_irqrestore (get_ccwdev_lock (base->cdev), flags);dasd_schedule_block_bh (block);
PATCH 23/52 dasd: remove strings from s390dbf
In reply to Martin SchwidefskyFrom: Stefan Haberland <[email protected]>
Remove strings from s390 debugfeature entries that could lead to a crash when the data is read from dbf because the strings do not exist any more.
---
drivers/s390/block/dasd.c | 22 ++++++++++---------- drivers/s390/block/dasd_eckd.c | 44 +++++++++++++++++------------------------ drivers/s390/block/dasd_fba.c | 10 +++------ drivers/s390/block/dasd_int.h | 10 +++++++++ 4 files changed, 44 insertions(+), 42 deletions(-)
drivers/s390/block/dasd.c +11 -11
@@ -994,10 +994,9 @@return ; cqr = (struct dasd_ccw_req *) intparm;if (cqr->status !=DASD_CQR_IN_IO ) { -DBF_EVENT (DBF_DEBUG , -"invalid status in handle_killed_request: " -"bus_id %s, status %02x" , -dev_name (&cdev->dev), cqr->status); +DBF_EVENT_DEVID (DBF_DEBUG , cdev, +"invalid status in handle_killed_request: " +"%02x" , cqr->status);return ; }
@@ -1045,12 +1044,13 @@case -EIO :break ;case -ETIMEDOUT : -DBF_EVENT (DBF_WARNING ,"%s(%s): request timed out\n" , - __func__,dev_name (&cdev->dev)); +DBF_EVENT_DEVID (DBF_WARNING , cdev,"%s: " +"request timed out\n" , __func__);break ;default : -DBF_EVENT (DBF_WARNING ,"%s(%s): unknown error %ld\n" , - __func__,dev_name (&cdev->dev),PTR_ERR (irb)); +DBF_EVENT_DEVID (DBF_WARNING , cdev,"%s: " +"unknown error %ld\n" , __func__, +PTR_ERR (irb)); }dasd_handle_killed_request (cdev, intparm);return ;
@@ -2310,9 +2310,9 @@ } ret =dasd_add_sysfs_files (cdev);if (ret) { -DBF_EVENT (DBF_WARNING , -"dasd_generic_probe: could not add sysfs entries " -"for %s\n" ,dev_name (&cdev->dev)); +DBF_EVENT_DEVID (DBF_WARNING , cdev,"%s" , +"dasd_generic_probe: could not add " +"sysfs entries" );return ret; } cdev->handler = &dasd_int_handler;
drivers/s390/block/dasd_eckd.c +19 -25
90 lines not on this page · raw message
drivers/s390/block/dasd_fba.c +4 -6
@@ -140,9 +140,8 @@ } block =dasd_alloc_block ();if (IS_ERR (block)) { -DBF_EVENT (DBF_WARNING ,"could not allocate dasd block " -"structure for device: %s" , -dev_name (&device->cdev->dev)); +DBF_EVENT_DEVID (DBF_WARNING , cdev,"%s" ,"could not allocate " +"dasd block structure" ); device->private =NULL ;kfree (private);return PTR_ERR (block);
@@ -154,9 +153,8 @@ rc =dasd_generic_read_dev_chars (device,DASD_FBA_MAGIC , &private->rdc_data,32 );if (rc) { -DBF_EVENT (DBF_WARNING ,"Read device characteristics returned " -"error %d for device: %s" , - rc,dev_name (&device->cdev->dev)); +DBF_EVENT_DEVID (DBF_WARNING , cdev,"Read device " +"characteristics returned error %d" , rc); device->block =NULL ;dasd_free_block (block); device->private =NULL ;
drivers/s390/block/dasd_int.h +10 -0
@@ -108,6 +108,16 @@ d_data); \ }while (0 ) +#define DBF_EVENT_DEVID(d_level, d_cdev, d_str, d_data...) \ +do { \ +struct ccw_dev_id __dev_id; \ +ccw_device_get_id (d_cdev, &__dev_id); \ +debug_sprintf_event (dasd_debug_area, \ + d_level, \ +"0.%x.%04x " d_str"\n" , \ + __dev_id.ssid, __dev_id.devno, d_data); \ +} while (0) + #define DBF_EXC(d_level, d_str, d_data...)\ do { \ debug_sprintf_exception(dasd_debug_area, \
PATCH 24/52 s390: use change recording override for kernel mapping
In reply to Martin SchwidefskyFrom: Christian Borntraeger <[email protected]>
We dont need the dirty bit if a write access is done via the kernel mapping. In that case SetPageDirty and friends are used anyway, no need to do that a second time. We can use the change-recording overide function for the kernel mapping, if available.
---
arch/s390/include/asm/pgtable.h | 4 +++- arch/s390/mm/vmem.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-)
arch/s390/include/asm/pgtable.h +3 -1
@@ -169,12 +169,13 @@* STL Segment-Table-Length: Segment-table length (STL+1*16 entries -> up to 2048) * * A 64 bit pagetable entry of S390 has following format: -* | PFRA |0IP0| OS | +* | PFRA |0IPC| OS | * 0000000000111111111122222222223333333333444444444455555555556666 * 0123456789012345678901234567890123456789012345678901234567890123 * * I Page-Invalid Bit: Page is not available for address-translation * P Page-Protection Bit: Store access not possible for page +* C Change-bit override: HW is not required to set change bit * * A 64 bit segmenttable entry of S390 has following format: * | P-table origin | TT
@@ -218,6 +219,7 @@*/ /* Hardware bits in the page table entry */ +#define _PAGE_CO 0x100/* HW Change-bit override */ #define _PAGE_RO 0x200/* HW read-only bit */ #define _PAGE_INVALID 0x400/* HW invalid bit */
arch/s390/mm/vmem.c +8 -3
@@ -70,8 +70,12 @@ pte =alloc_bootmem (PTRS_PER_PTE *sizeof (pte_t));if (!pte)return NULL ; -clear_table ((unsigned long *) pte, _PAGE_TYPE_EMPTY, -PTRS_PER_PTE *sizeof (pte_t)); +if (MACHINE_HAS_HPAGE ) +clear_table ((unsigned long *) pte, _PAGE_TYPE_EMPTY | _PAGE_CO, +PTRS_PER_PTE *sizeof (pte_t)); +else +clear_table ((unsigned long *) pte, _PAGE_TYPE_EMPTY, +PTRS_PER_PTE *sizeof (pte_t));return pte; }
@@ -112,7 +116,8 @@if (MACHINE_HAS_HPAGE && !(address & ~HPAGE_MASK ) && (address +HPAGE_SIZE <= start + size) && (address >=HPAGE_SIZE )) { -pte_val (pte) |= _SEGMENT_ENTRY_LARGE; +pte_val (pte) |= _SEGMENT_ENTRY_LARGE | + _SEGMENT_ENTRY_CO;pmd_val (*pm_dir) =pte_val (pte); address +=HPAGE_SIZE -PAGE_SIZE ;continue ;
PATCH 25/52 sclp: improve servicability setting
In reply to Martin SchwidefskyFrom: Martin Schwidefsky <[email protected]>
Set dump indicator on read-scp-info command to get meaningful dumps.
---
drivers/s390/char/sclp_cmd.c | 1 + 1 file changed, 1 insertion(+)
drivers/s390/char/sclp_cmd.c +1 -0
@@ -84,6 +84,7 @@do {memset (sccb,0 ,sizeof (*sccb)); sccb->header.length =sizeof (*sccb); + sccb->header.function_code =0x80 ; sccb->header.control_mask[2 ] =0x80 ; rc =sclp_cmd_sync_early (commands[i], sccb); }while (rc == -EBUSY );
PATCH 26/52 cio: fix double free in case of probe failure
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
io_subchannel_probe() frees memory for sch->private which is later freed again when io_subchannel_remove() is called. Fix this problem by removing the cleanup in io_subchannel_probe().
---
drivers/s390/cio/device.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/s390/cio/device.c +5 -6
@@ -1292,7 +1292,7 @@ sch->private =kzalloc (sizeof (struct io_subchannel_private ),GFP_KERNEL |GFP_DMA );if (!sch->private) - goto out_err; + goto out_schedule;/* * First check if a fitting device may be found amongst the * disconnected devices or in the orphanage.
@@ -1317,7 +1317,7 @@ } cdev =io_subchannel_create_ccwdev (sch);if (IS_ERR (cdev)) - goto out_err; + goto out_schedule; rc =io_subchannel_recog (cdev, sch);if (rc) {spin_lock_irqsave (sch->lock, flags);
@@ -1325,9 +1325,7 @@spin_unlock_irqrestore (sch->lock, flags); }return 0 ; -out_err: -kfree (sch->private); -sysfs_remove_group (&sch->dev.kobj, &io_subchannel_attr_group); + out_schedule:io_subchannel_schedule_removal (sch);return 0 ;
@@ -1341,13 +1339,14 @@ cdev =sch_get_cdev (sch);if (!cdev) -return 0 ; + goto out_free;/* Set ccw device to not operational and drop reference. */ spin_lock_irqsave (cdev->ccwlock, flags);sch_set_cdev (sch,NULL ); cdev->private->state =DEV_STATE_NOT_OPER ;spin_unlock_irqrestore (cdev->ccwlock, flags);ccw_device_unregister (cdev); +out_free:kfree (sch->private);sysfs_remove_group (&sch->dev.kobj, &io_subchannel_attr_group);return 0 ;
PATCH 27/52 cio: fix repeat setting of cdev parent association
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
sch_create_and_recog_new_device() associates a parent subchannel with its ccw device child even though this is already done by the subsequently called io_subchannel_recog(). Also make sure io_subchannel_recog() sets the association under lock.
---
drivers/s390/cio/device.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/s390/cio/device.c +1 -4
@@ -888,9 +888,6 @@css_sch_device_unregister (sch);return ; } -spin_lock_irq (sch->lock); -sch_set_cdev (sch, cdev); -spin_unlock_irq (sch->lock);/* Start recognition for the new ccw device. */ if (io_subchannel_recog (cdev, sch)) {spin_lock_irq (sch->lock);
@@ -1107,7 +1104,6 @@int rc;struct ccw_device_private *priv; -sch_set_cdev (sch, cdev); cdev->ccwlock = sch->lock;/* Init private data. */
@@ -1125,6 +1121,7 @@/* Start async. device sensing. */ spin_lock_irq (sch->lock); +sch_set_cdev (sch, cdev); rc =ccw_device_recognition (cdev);spin_unlock_irq (sch->lock);if (rc) {
PATCH 28/52 cio: introduce parent-initiated device move
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
Change the initiative to update subchannel-ccw device associations to the subchannel: when there is an indication that the internal association no longer reflects the current hardware state, mark each affected subchannel as requiring attention. Once processing reaches a subchannel, determine the correct association for that subchannel at that time and perform the necessary device_move operations.
This change fixes problems with the previous approach which would leave devices in an inconsistent state when a new hardware change occurred while a device_move was already scheduled.
---
drivers/s390/cio/css.c | 9 drivers/s390/cio/device.c | 515 ++++++++++++++---------------------------- drivers/s390/cio/device_fsm.c | 8 3 files changed, 193 insertions(+), 339 deletions(-)
drivers/s390/cio/css.c +7 -2
@@ -376,8 +376,8 @@/* Unusable - ignore. */ return 0 ; } -CIO_MSG_EVENT (4 ,"Evaluating schid 0.%x.%04x, event %d, unknown, " -"slow path.\n" , schid.ssid, schid.sch_no,CIO_OPER ); +CIO_MSG_EVENT (4 ,"event: sch 0.%x.%04x, new\n" , schid.ssid, + schid.sch_no);return css_probe_device (schid); }
@@ -394,6 +394,10 @@"Got subchannel machine check but " "no sch_event handler provided.\n"); } +if (ret !=0 && ret != -EAGAIN ) { +CIO_MSG_EVENT (2 ,"eval: sch 0.%x.%04x, rc=%d\n" , + sch->schid.ssid, sch->schid.sch_no, ret); + }return ret; }
@@ -684,6 +688,7 @@ css->pseudo_subchannel->dev.parent = &css->device; css->pseudo_subchannel->dev.release = css_subchannel_release;dev_set_name (&css->pseudo_subchannel->dev,"defunct" ); +mutex_init (&css->pseudo_subchannel->reg_mutex); ret =cio_create_sch_lock (css->pseudo_subchannel);if (ret) {kfree (css->pseudo_subchannel);
drivers/s390/cio/device.c +183 -332
609 lines not on this page · raw message
drivers/s390/cio/device_fsm.c +3 -5
@@ -1072,11 +1072,9 @@/* We should also udate ssd info, but this has to wait. */ /* Check if this is another device which appeared on the same sch. */ -if (sch->schib.pmcw.dev != cdev->private->dev_id.devno) { -PREPARE_WORK (&cdev->private->kick_work, - ccw_device_move_to_orphanage); -queue_work (slow_path_wq, &cdev->private->kick_work); - }else +if (sch->schib.pmcw.dev != cdev->private->dev_id.devno) +css_schedule_eval (sch->schid); +else ccw_device_start_id (cdev,0 ); }
PATCH 29/52 cio: introduce subchannel todos
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
Ensure that current and future users of sch->work do not overwrite each other by introducing a single mechanism for delayed subchannel work.
---
drivers/s390/cio/cio.h | 8 ++++++- drivers/s390/cio/css.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/s390/cio/css.h | 3 ++ drivers/s390/cio/device.c | 23 ++++------------------ 4 files changed, 63 insertions(+), 19 deletions(-)
drivers/s390/cio/cio.h +7 -1
@@ -68,6 +68,11 @@__u8 mda[4 ];/* model dependent area */ } __attribute__ ((packed,aligned(4))); +enum sch_todo { +SCH_TODO_NOTHING , +SCH_TODO_UNREG , +}; +/* subchannel data structure used by I/O subroutines */ struct subchannel {struct subchannel_id schid;
@@ -95,7 +100,8 @@struct device dev;/* entry in device tree */ struct css_driver *driver;void *private;/* private per subchannel type data */ -struct work_struct work; +enum sch_todo todo; +struct work_struct todo_work;struct schib_config config; } __attribute__ ((aligned(8)));
drivers/s390/cio/css.c +48 -0
66 lines not on this page · raw message
drivers/s390/cio/css.h +3 -0
@@ -11,6 +11,8 @@#include <asm/chpid.h> #include <asm/schid.h> +#include "cio.h" +/* * path grouping stuff */
@@ -151,4 +153,5 @@extern struct workqueue_struct *slow_path_wq;void css_wait_for_slow_path (void ); +void css_sched_sch_todo (struct subchannel *sch,enum sch_todo todo);#endif
drivers/s390/cio/device.c +5 -18
@@ -1051,23 +1051,6 @@io_subchannel_init_config (sch); } -static void io_subchannel_do_unreg (struct work_struct *work) -{ -struct subchannel *sch; - - sch = container_of(work, struct subchannel, work); -css_sch_device_unregister (sch); -put_device (&sch->dev); -} - -/* Schedule unregister if we have no cdev. */ -static void io_subchannel_schedule_removal (struct subchannel *sch) -{ -get_device (&sch->dev); -INIT_WORK (&sch->work, io_subchannel_do_unreg); -queue_work (slow_path_wq, &sch->work); -} -/* * Note: We always return 0 so that we bind to the device even on error. * This is needed so that our remove function is called on unregister.
@@ -1124,7 +1107,9 @@return 0 ; out_schedule: -io_subchannel_schedule_removal (sch); +spin_lock_irq (sch->lock); +css_sched_sch_todo (sch,SCH_TODO_UNREG ); +spin_unlock_irq (sch->lock);return 0 ; }
@@ -1469,6 +1454,8 @@spin_lock_irqsave (sch->lock, flags);if (!device_is_registered (&sch->dev)) goto out_unlock; +if (work_pending (&sch->todo_work)) + goto out_unlock; action =sch_get_action (sch); CIO_MSG_EVENT(2, "event: sch 0.%x.%04x, process=%d, action=%d\n", sch->schid.ssid, sch->schid.sch_no, process,
PATCH 30/52 cio: introduce ccw device todos
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
Introduce a central mechanism for performing delayed ccw device work to ensure that different types of work do not overwrite each other. Prioritization ensures that the most important work is always performed while less important tasks are either obsoleted or repeated later.
---
drivers/s390/cio/device.c | 203 ++++++++++++++++++++---------------------- drivers/s390/cio/device.h | 3 drivers/s390/cio/device_fsm.c | 28 +---- drivers/s390/cio/io_sch.h | 12 ++ 4 files changed, 119 insertions(+), 127 deletions(-)
drivers/s390/cio/device.c +100 -103
@@ -306,47 +306,6 @@ } } -static void ccw_device_remove_orphan_cb (struct work_struct *work) -{ -struct ccw_device_private *priv; -struct ccw_device *cdev; - - priv = container_of(work, struct ccw_device_private, kick_work); - cdev = priv->cdev; -ccw_device_unregister (cdev); -/* Release cdev reference for workqueue processing. */ -put_device (&cdev->dev); -} - -static void -ccw_device_remove_disconnected (struct ccw_device *cdev) -{ -unsigned long flags; - -/* -* Forced offline in disconnected state means -* 'throw away device'. -*/ -if (ccw_device_is_orphan (cdev)) { -/* -* Deregister ccw device. -* Unfortunately, we cannot do this directly from the -* attribute method. -*/ -/* Get cdev reference for workqueue processing. */ -if (!get_device (&cdev->dev)) -return ; -spin_lock_irqsave (cdev->ccwlock, flags); - cdev->private->state =DEV_STATE_NOT_OPER ; -spin_unlock_irqrestore (cdev->ccwlock, flags); -PREPARE_WORK (&cdev->private->kick_work, - ccw_device_remove_orphan_cb); -queue_work (slow_path_wq, &cdev->private->kick_work); - }else -/* Deregister subchannel, which will kill the ccw device. */ -ccw_device_schedule_sch_unregister (cdev); -} -/** * ccw_device_set_offline() - disable a ccw device for I/O * @cdev: target ccw device
@@ -494,9 +453,11 @@static int online_store_handle_offline (struct ccw_device *cdev) { -if (cdev->private->state ==DEV_STATE_DISCONNECTED ) -ccw_device_remove_disconnected (cdev); -else if (cdev->online && cdev->drv && cdev->drv->set_offline) +if (cdev->private->state ==DEV_STATE_DISCONNECTED ) { +spin_lock_irq (cdev->ccwlock); +ccw_device_sched_todo (cdev,CDEV_TODO_UNREG_EVAL ); +spin_unlock_irq (cdev->ccwlock); + }else if (cdev->online && cdev->drv && cdev->drv->set_offline)return ccw_device_set_offline (cdev);return 0 ; }
@@ -690,17 +651,10 @@return dev ?to_ccwdev (dev) :NULL ; } -void ccw_device_do_unbind_bind (struct work_struct *work) +static void ccw_device_do_unbind_bind (struct ccw_device *cdev) { -struct ccw_device_private *priv; -struct ccw_device *cdev; -struct subchannel *sch;int ret; - priv = container_of(work, struct ccw_device_private, kick_work); - cdev = priv->cdev; - sch =to_subchannel (cdev->dev.parent); -if (test_bit (1 , &cdev->private->registered)) {device_release_driver (&cdev->dev); ret =device_attach (&cdev->dev);
@@ -735,6 +689,8 @@return ERR_PTR (-ENOMEM ); } +static void ccw_device_todo (struct work_struct *work); +static int io_subchannel_initialize_dev (struct subchannel *sch,struct ccw_device *cdev) {
@@ -742,7 +698,7 @@atomic_set (&cdev->private->onoff,0 ); cdev->dev.parent = &sch->dev; cdev->dev.release = ccw_device_release; -INIT_WORK (&cdev->private->kick_work,NULL ); +INIT_WORK (&cdev->private->todo_work, ccw_device_todo); cdev->dev.groups = ccwdev_attr_groups;/* Do first half of device_register. */ device_initialize (&cdev->dev);
@@ -797,17 +753,12 @@/* * Register recognized device. */ -static void -io_subchannel_register (struct work_struct *work) +static void io_subchannel_register (struct ccw_device *cdev) { -struct ccw_device_private *priv; -struct ccw_device *cdev;struct subchannel *sch;int ret;unsigned long flags; - priv = container_of(work, struct ccw_device_private, kick_work); - cdev = priv->cdev; sch =to_subchannel (cdev->dev.parent);/* * Check if subchannel is still registered. It may have become
@@ -859,41 +810,23 @@ cdev->private->flags.recog_done =1 ;wake_up (&cdev->private->wait_q); out_err: -/* Release reference for workqueue processing. */ -put_device (&cdev->dev);if (atomic_dec_and_test (&ccw_device_init_count))wake_up (&ccw_device_init_wq); } -static void ccw_device_call_sch_unregister (struct work_struct *work) +static void ccw_device_call_sch_unregister (struct ccw_device *cdev) { -struct ccw_device_private *priv; -struct ccw_device *cdev;struct subchannel *sch; - priv = container_of(work, struct ccw_device_private, kick_work); - cdev = priv->cdev;/* Get subchannel reference for local processing. */ if (!get_device (cdev->dev.parent))return ; sch =to_subchannel (cdev->dev.parent);css_sch_device_unregister (sch); -/* Release cdev reference for workqueue processing.*/ -put_device (&cdev->dev);/* Release subchannel reference for local processing. */ put_device (&sch->dev); } -void ccw_device_schedule_sch_unregister (struct ccw_device *cdev) -{ -/* Get cdev reference for workqueue processing. */ -if (!get_device (&cdev->dev)) -return ; -PREPARE_WORK (&cdev->private->kick_work, - ccw_device_call_sch_unregister); -queue_work (slow_path_wq, &cdev->private->kick_work); -} -/* * subchannel recognition done. Called from the state machine. */
@@ -909,7 +842,8 @@/* Device did not respond in time. */ case DEV_STATE_NOT_OPER : cdev->private->flags.recog_done =1 ; -ccw_device_schedule_sch_unregister (cdev); +/* Remove device found not operational. */ +ccw_device_sched_todo (cdev,CDEV_TODO_UNREG );if (atomic_dec_and_test (&ccw_device_init_count))wake_up (&ccw_device_init_wq);break ;
@@ -918,11 +852,7 @@* We can't register the device in interrupt context so * we schedule a work item. */ -if (!get_device (&cdev->dev)) -break ; -PREPARE_WORK (&cdev->private->kick_work, - io_subchannel_register); -queue_work (slow_path_wq, &cdev->private->kick_work); +ccw_device_sched_todo (cdev,CDEV_TODO_REGISTER );break ; } }
@@ -1333,20 +1263,16 @@static int purge_fn (struct device *dev,void *data) {struct ccw_device *cdev =to_ccwdev (dev); -struct ccw_device_private *priv = cdev->private; -int unreg; +struct ccw_dev_id *id = &cdev->private->dev_id;spin_lock_irq (cdev->ccwlock); - unreg =is_blacklisted (priv->dev_id.ssid, priv->dev_id.devno) && - (priv->state ==DEV_STATE_OFFLINE ); +if (is_blacklisted (id->ssid, id->devno) && + (cdev->private->state ==DEV_STATE_OFFLINE )) { +CIO_MSG_EVENT (3 ,"ccw: purging 0.%x.%04x\n" , id->ssid, + id->devno); +ccw_device_sched_todo (cdev,CDEV_TODO_UNREG ); + }spin_unlock_irq (cdev->ccwlock); -if (!unreg) - goto out; -CIO_MSG_EVENT (3 ,"ccw: purging 0.%x.%04x\n" , priv->dev_id.ssid, - priv->dev_id.devno); -ccw_device_schedule_sch_unregister (cdev); - -out:/* Abort loop in case of pending signal. */ if (signal_pending (current))return -EINTR ;
@@ -1456,12 +1382,14 @@ goto out_unlock;if (work_pending (&sch->todo_work)) goto out_unlock; + cdev =sch_get_cdev (sch); +if (cdev &&work_pending (&cdev->private->todo_work)) + goto out_unlock; action =sch_get_action (sch);CIO_MSG_EVENT (2 ,"event: sch 0.%x.%04x, process=%d, action=%d\n" , sch->schid.ssid, sch->schid.sch_no, process, action);/* Perform immediate actions while holding the lock. */ - cdev =sch_get_cdev (sch);switch (action) {case IO_SCH_REPROBE :/* Trigger device recognition. */
@@ -1753,7 +1681,7 @@ {struct ccw_device *cdev =to_ccwdev (dev); -if (work_pending (&cdev->private->kick_work)) +if (work_pending (&cdev->private->todo_work))return -EAGAIN ;/* Fail while device is being set online/offline. */ if (atomic_read (&cdev->private->onoff))
@@ -1874,7 +1802,7 @@ cdev->private->state =DEV_STATE_BOXED ;if (ccw_device_notify (cdev,CIO_BOXED ))return 0 ; -ccw_device_schedule_sch_unregister (cdev); +ccw_device_sched_todo (cdev,CDEV_TODO_UNREG );return -ENODEV ; }
@@ -1883,7 +1811,7 @@ cdev->private->state =DEV_STATE_DISCONNECTED ;if (ccw_device_notify (cdev,CIO_GONE ))return 0 ; -ccw_device_schedule_sch_unregister (cdev); +ccw_device_sched_todo (cdev,CDEV_TODO_UNREG );return -ENODEV ; }
@@ -1928,9 +1856,7 @@/* check if the device type has changed */ if (!ccw_device_test_sense_data (cdev)) {ccw_device_update_sense_data (cdev); -PREPARE_WORK (&cdev->private->kick_work, - ccw_device_do_unbind_bind); -queue_work (ccw_device_work, &cdev->private->kick_work); +ccw_device_sched_todo (cdev,CDEV_TODO_REBIND ); ret = -ENODEV ; goto out_unlock; }
@@ -1974,7 +1900,7 @@ goto out_restore; out_unreg_unlock: -ccw_device_schedule_sch_unregister (cdev); +ccw_device_sched_todo (cdev,CDEV_TODO_UNREG_EVAL ); ret = -ENODEV ; out_unlock:spin_unlock_irq (sch->lock);
@@ -2039,6 +1965,77 @@return sch->schid; } +static void ccw_device_todo (struct work_struct *work) +{ +struct ccw_device_private *priv; +struct ccw_device *cdev; +struct subchannel *sch; +enum cdev_todo todo; + + priv = container_of(work, struct ccw_device_private, todo_work); + cdev = priv->cdev; + sch =to_subchannel (cdev->dev.parent); +/* Find out todo. */ +spin_lock_irq (cdev->ccwlock); + todo = priv->todo; + priv->todo =CDEV_TODO_NOTHING ; +CIO_MSG_EVENT (4 ,"cdev_todo: cdev=0.%x.%04x todo=%d\n" , + priv->dev_id.ssid, priv->dev_id.devno, todo); +spin_unlock_irq (cdev->ccwlock); +/* Perform todo. */ +switch (todo) { +case CDEV_TODO_ENABLE_CMF : +cmf_reenable (cdev); +break ; +case CDEV_TODO_REBIND : +ccw_device_do_unbind_bind (cdev); +break ; +case CDEV_TODO_REGISTER : +io_subchannel_register (cdev); +break ; +case CDEV_TODO_UNREG_EVAL : +if (!sch_is_pseudo_sch (sch)) +css_schedule_eval (sch->schid); +/* fall-through */ +case CDEV_TODO_UNREG : +if (sch_is_pseudo_sch (sch)) +ccw_device_unregister (cdev); +else +ccw_device_call_sch_unregister (cdev); +break ; +default : +break ; + } +/* Release workqueue ref. */ +put_device (&cdev->dev); +} + +/** +* ccw_device_sched_todo - schedule ccw device operation +* @cdev: ccw device +* @todo: todo +* +* Schedule the operation identified by @todo to be performed on the slow path +* workqueue. Do nothing if another operation with higher priority is already +* scheduled. Needs to be called with ccwdev lock held. +*/ +void ccw_device_sched_todo (struct ccw_device *cdev,enum cdev_todo todo) +{ +CIO_MSG_EVENT (4 ,"cdev_todo: sched cdev=0.%x.%04x todo=%d\n" , + cdev->private->dev_id.ssid, cdev->private->dev_id.devno, + todo); +if (cdev->private->todo >= todo) +return ; + cdev->private->todo = todo; +/* Get workqueue ref. */ +if (!get_device (&cdev->dev)) +return ; +if (!queue_work (slow_path_wq, &cdev->private->todo_work)) { +/* Already queued, release workqueue ref. */ +put_device (&cdev->dev); + } +} +MODULE_LICENSE ("GPL" );EXPORT_SYMBOL (ccw_device_set_online);EXPORT_SYMBOL (ccw_device_set_offline);
drivers/s390/cio/device_fsm.c +7 -21
@@ -289,9 +289,7 @@wake_up (&cdev->private->wait_q); }else {ccw_device_update_sense_data (cdev); -PREPARE_WORK (&cdev->private->kick_work, - ccw_device_do_unbind_bind); -queue_work (ccw_device_work, &cdev->private->kick_work); +ccw_device_sched_todo (cdev,CDEV_TODO_REBIND ); }return ;case DEV_STATE_BOXED :
@@ -343,28 +341,16 @@return cdev->drv->notify ? cdev->drv->notify (cdev, event) :0 ; } -static void cmf_reenable_delayed (struct work_struct *work) -{ -struct ccw_device_private *priv; -struct ccw_device *cdev; - - priv = container_of(work, struct ccw_device_private, kick_work); - cdev = priv->cdev; -cmf_reenable (cdev); -} -static void ccw_device_oper_notify (struct ccw_device *cdev) {if (ccw_device_notify (cdev,CIO_OPER )) {/* Reenable channel measurements, if needed. */ -PREPARE_WORK (&cdev->private->kick_work, cmf_reenable_delayed); -queue_work (ccw_device_work, &cdev->private->kick_work); +ccw_device_sched_todo (cdev,CDEV_TODO_ENABLE_CMF );return ; }/* Driver doesn't want device back. */ ccw_device_set_notoper (cdev); -PREPARE_WORK (&cdev->private->kick_work, ccw_device_do_unbind_bind); -queue_work (ccw_device_work, &cdev->private->kick_work); +ccw_device_sched_todo (cdev,CDEV_TODO_REBIND ); }/*
@@ -392,14 +378,14 @@CIO_MSG_EVENT (0 ,"Boxed device %04x on subchannel %04x\n" , cdev->private->dev_id.devno, sch->schid.sch_no);if (cdev->online && !ccw_device_notify (cdev,CIO_BOXED )) -ccw_device_schedule_sch_unregister (cdev); +ccw_device_sched_todo (cdev,CDEV_TODO_UNREG ); cdev->private->flags.donotify =0 ;break ;case DEV_STATE_NOT_OPER :CIO_MSG_EVENT (0 ,"Device %04x gone on subchannel %04x\n" , cdev->private->dev_id.devno, sch->schid.sch_no);if (!ccw_device_notify (cdev,CIO_GONE )) -ccw_device_schedule_sch_unregister (cdev); +ccw_device_sched_todo (cdev,CDEV_TODO_UNREG );else ccw_device_set_disconnected (cdev); cdev->private->flags.donotify =0 ;
@@ -409,7 +395,7 @@"%04x\n" , cdev->private->dev_id.devno, sch->schid.sch_no);if (!ccw_device_notify (cdev,CIO_NO_PATH )) -ccw_device_schedule_sch_unregister (cdev); +ccw_device_sched_todo (cdev,CDEV_TODO_UNREG );else ccw_device_set_disconnected (cdev); cdev->private->flags.donotify =0 ;
@@ -751,7 +737,7 @@ enum dev_event dev_event) {if (!ccw_device_notify (cdev,CIO_GONE )) -ccw_device_schedule_sch_unregister (cdev); +ccw_device_sched_todo (cdev,CDEV_TODO_UNREG );else ccw_device_set_disconnected (cdev); }
drivers/s390/cio/device.h +1 -2
@@ -81,8 +81,6 @@int ccw_device_cancel_halt_clear (struct ccw_device *); -void ccw_device_do_unbind_bind (struct work_struct *); -void ccw_device_move_to_orphanage (struct work_struct *);int ccw_device_is_orphan (struct ccw_device *);int ccw_device_recognition (struct ccw_device *);
@@ -92,6 +90,7 @@int ccw_device_test_sense_data (struct ccw_device *);void ccw_device_schedule_sch_unregister (struct ccw_device *);int ccw_purge_blacklisted (void ); +void ccw_device_sched_todo (struct ccw_device *cdev,enum cdev_todo todo);/* Function prototypes for device status and basic sense stuff. */ void ccw_device_accumulate_irb (struct ccw_device *,struct irb *);
drivers/s390/cio/io_sch.h +11 -1
@@ -82,6 +82,15 @@struct ciw ciw[MAX_CIWS ];/* variable # of CIWs */ } __attribute__ ((packed, aligned(4))); +enum cdev_todo { +CDEV_TODO_NOTHING , +CDEV_TODO_ENABLE_CMF , +CDEV_TODO_REBIND , +CDEV_TODO_REGISTER , +CDEV_TODO_UNREG , +CDEV_TODO_UNREG_EVAL , +}; +struct ccw_device_private {struct ccw_device *cdev;struct subchannel *sch;
@@ -115,7 +124,8 @@struct senseid senseid;/* SenseID info */ struct pgid pgid[8 ];/* path group IDs per chpid*/ struct ccw1 iccws[2 ];/* ccws for SNID/SID/SPGID commands */ -struct work_struct kick_work; +struct work_struct todo_work; +enum cdev_todo todo;wait_queue_head_t wait_q;struct timer_list timer;void *cmb;/* measurement information */
PATCH 31/52 cio: inform user when online/offline processing fails
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
Print a warning message in case a ccw device enters boxed or not operational state during online/offline processing.
---
drivers/s390/cio/device.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/s390/cio/device.c +22 -0
@@ -7,6 +7,10 @@* Cornelia Huck ([email protected]) * Martin Schwidefsky ([email protected]) */ + +#define KMSG_COMPONENT "cio" +#define pr_fmt (fmt) KMSG_COMPONENT ": " fmt +#include <linux/module.h> #include <linux/init.h> #include <linux/spinlock.h>
@@ -347,6 +351,14 @@spin_unlock_irq (cdev->ccwlock);wait_event (cdev->private->wait_q, (dev_fsm_final_state (cdev) || cdev->private->state ==DEV_STATE_DISCONNECTED )); +/* Inform the user if set offline failed. */ +if (cdev->private->state ==DEV_STATE_BOXED ) { +pr_warning ("%s: The device entered boxed state while " +"being set offline\n" ,dev_name (&cdev->dev)); + }else if (cdev->private->state ==DEV_STATE_NOT_OPER ) { +pr_warning ("%s: The device stopped operating while " +"being set offline\n" ,dev_name (&cdev->dev)); + }/* Give up reference from ccw_device_set_online(). */ put_device (&cdev->dev);return 0 ;
@@ -407,6 +419,16 @@if ((cdev->private->state !=DEV_STATE_ONLINE ) && (cdev->private->state !=DEV_STATE_W4SENSE )) {spin_unlock_irq (cdev->ccwlock); +/* Inform the user that set online failed. */ +if (cdev->private->state ==DEV_STATE_BOXED ) { +pr_warning ("%s: Setting the device online failed " +"because it is boxed\n" , +dev_name (&cdev->dev)); + }else if (cdev->private->state ==DEV_STATE_NOT_OPER ) { +pr_warning ("%s: Setting the device online failed " +"because it is not operational\n" , +dev_name (&cdev->dev)); + }/* Give up online reference since onlining failed. */ put_device (&cdev->dev);return -ENODEV ;
PATCH 32/52 cio: handle error during device recognition consistently
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
Remove the return code from ccw_device_recognition and handle recognition errors through the existing callback ccw_device_recog_done to reduce cleanup code duplication.
---
drivers/s390/cio/device.c | 57 +++++------------------------------------- drivers/s390/cio/device.h | 2 - drivers/s390/cio/device_fsm.c | 20 ++++---------- 3 files changed, 15 insertions(+), 64 deletions(-)
drivers/s390/cio/device.c +8 -49
@@ -486,18 +486,9 @@static int online_store_recog_and_online (struct ccw_device *cdev) { -int ret; -/* Do device recognition, if needed. */ if (cdev->private->state ==DEV_STATE_BOXED ) { - ret =ccw_device_recognition (cdev); -if (ret) { -CIO_MSG_EVENT (0 ,"Couldn't start recognition " -"for device 0.%x.%04x (ret=%d)\n" , - cdev->private->dev_id.ssid, - cdev->private->dev_id.devno, ret); -return ret; - } +ccw_device_recognition (cdev);wait_event (cdev->private->wait_q, cdev->private->flags.recog_done);if (cdev->private->state !=DEV_STATE_OFFLINE )
@@ -746,7 +737,7 @@return cdev; } -static int io_subchannel_recog (struct ccw_device *,struct subchannel *); +static void io_subchannel_recog (struct ccw_device *,struct subchannel *);static void sch_create_and_recog_new_device (struct subchannel *sch) {
@@ -760,16 +751,7 @@return ; }/* Start recognition for the new ccw device. */ -if (io_subchannel_recog (cdev, sch)) { -spin_lock_irq (sch->lock); -sch_set_cdev (sch,NULL ); -spin_unlock_irq (sch->lock); -css_sch_device_unregister (sch); -/* Put reference from io_subchannel_create_ccwdev(). */ -put_device (&sch->dev); -/* Give up initial reference. */ -put_device (&cdev->dev); - } +io_subchannel_recog (cdev, sch); }/*
@@ -879,10 +861,8 @@ } } -static int -io_subchannel_recog (struct ccw_device *cdev,struct subchannel *sch) +static void io_subchannel_recog (struct ccw_device *cdev,struct subchannel *sch) { -int rc;struct ccw_device_private *priv; cdev->ccwlock = sch->lock;
@@ -903,13 +883,8 @@/* Start async. device sensing. */ spin_lock_irq (sch->lock);sch_set_cdev (sch, cdev); - rc =ccw_device_recognition (cdev); +ccw_device_recognition (cdev);spin_unlock_irq (sch->lock); -if (rc) { -if (atomic_dec_and_test (&ccw_device_init_count)) -wake_up (&ccw_device_init_wq); - } -return rc; } static int ccw_device_move_to_sch(struct ccw_device *cdev,
@@ -1528,10 +1503,7 @@ sch->driver = &io_subchannel_driver;/* Initialize the ccw_device structure. */ cdev->dev.parent= &sch->dev; - rc =io_subchannel_recog (cdev, sch); -if (rc) -return rc; - +io_subchannel_recog (cdev, sch);/* Now wait for the async. recognition to come to an end. */ spin_lock_irq (cdev->ccwlock);while (!dev_fsm_final_state (cdev))
@@ -1547,7 +1519,7 @@ rc =0 ; out_unlock:spin_unlock_irq (cdev->ccwlock); -return 0 ; +return rc; } struct ccw_device *
@@ -1789,7 +1761,6 @@static void __ccw_device_pm_restore (struct ccw_device *cdev) {struct subchannel *sch =to_subchannel (cdev->dev.parent); -int ret;if (cio_is_console (sch->schid)) goto out;
@@ -1799,22 +1770,10 @@*/ spin_lock_irq (sch->lock); cdev->private->flags.resuming =1 ; - ret =ccw_device_recognition (cdev); +ccw_device_recognition (cdev);spin_unlock_irq (sch->lock); -if (ret) { -CIO_MSG_EVENT (0 ,"Couldn't start recognition for device " -"0.%x.%04x (ret=%d)\n" , - cdev->private->dev_id.ssid, - cdev->private->dev_id.devno, ret); -spin_lock_irq (sch->lock); - cdev->private->state =DEV_STATE_DISCONNECTED ; -spin_unlock_irq (sch->lock); -/* notify driver after the resume cb */ - goto out; - }wait_event (cdev->private->wait_q,dev_fsm_final_state (cdev) || cdev->private->state ==DEV_STATE_DISCONNECTED ); - out: cdev->private->flags.resuming =0 ; }
drivers/s390/cio/device_fsm.c +6 -14
@@ -498,20 +498,9 @@/* * Start device recognition. */ -int -ccw_device_recognition (struct ccw_device *cdev) +void ccw_device_recognition (struct ccw_device *cdev) { -struct subchannel *sch; -int ret; - - sch =to_subchannel (cdev->dev.parent); - ret =cio_enable_subchannel (sch, (u32 )(addr_t )sch); -if (ret !=0 ) -/* Couldn't enable the subchannel for i/o. Sick device. */ -return ret; - -/* After 60s the device recognition is considered to have failed. */ -ccw_device_set_timeout (cdev,60 *HZ ); +struct subchannel *sch =to_subchannel (cdev->dev.parent);/* * We used to start here with a sense pgid to find out whether a device
@@ -523,8 +512,11 @@*/ cdev->private->flags.recog_done =0 ; cdev->private->state =DEV_STATE_SENSE_ID ; +if (cio_enable_subchannel (sch, (u32 ) (addr_t ) sch)) { +ccw_device_recog_done (cdev,DEV_STATE_NOT_OPER ); +return ; + }ccw_device_sense_id_start (cdev); -return 0 ; }/*
drivers/s390/cio/device.h +1 -1
@@ -83,7 +83,7 @@int ccw_device_is_orphan (struct ccw_device *); -int ccw_device_recognition (struct ccw_device *); +void ccw_device_recognition (struct ccw_device *);int ccw_device_online (struct ccw_device *);int ccw_device_offline (struct ccw_device *);void ccw_device_update_sense_data (struct ccw_device *);
PATCH 33/52 cio: handle error during path verification consistently
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
Handle verification errors consistently through the existing callback ccw_device_done to reduce cleanup code duplication.
---
drivers/s390/cio/device_fsm.c | 19 +++++++++---------- drivers/s390/cio/device_pgid.c | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-)
drivers/s390/cio/device_fsm.c +9 -10
@@ -549,9 +549,8 @@ sch =to_subchannel (cdev->dev.parent);/* Update schib - pom may have changed. */ if (cio_update_schib (sch)) { - cdev->private->flags.donotify =0 ; -ccw_device_done (cdev,DEV_STATE_NOT_OPER ); -return ; + err = -ENODEV ; + goto callback; }/* Update lpm with verified path mask. */ sch->lpm = sch->vpm;
@@ -561,9 +560,8 @@ccw_device_verify_start (cdev);return ; } +callback:switch (err) { -case -EOPNOTSUPP :/* path grouping not supported, just set online. */ - cdev->private->options.pgroup =0 ;case 0 :ccw_device_done (cdev,DEV_STATE_ONLINE );/* Deliver fake irb to device driver, if needed. */
@@ -586,14 +584,15 @@ cdev->private->flags.donotify =0 ;ccw_device_done (cdev,DEV_STATE_BOXED );break ; +case -EACCES : +/* Reset oper notify indication after verify error. */ + cdev->private->flags.donotify =0 ; +ccw_device_done (cdev,DEV_STATE_DISCONNECTED ); +break ;default :/* Reset oper notify indication after verify error. */ cdev->private->flags.donotify =0 ; -if (cdev->online) { -ccw_device_set_timeout (cdev,0 ); -dev_fsm_event (cdev,DEV_EVENT_NOTOPER ); - }else -ccw_device_done (cdev,DEV_STATE_NOT_OPER ); +ccw_device_done (cdev,DEV_STATE_NOT_OPER );break ; } }
drivers/s390/cio/device_pgid.c +1 -1
@@ -423,7 +423,7 @@/* Permanent path failure, try next. */ }/* Done with all paths. */ -ccw_device_verify_done (cdev, (sch->vpm !=0 ) ?0 : -ENODEV ); +ccw_device_verify_done (cdev, (sch->vpm !=0 ) ?0 : -EACCES ); }/*
PATCH 34/52 cio: ensure proper locking during device recognition
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
Device recognition needs to be started with the ccw device lock held to prevent race conditions between I/O starting and interrupt reception.
---
drivers/s390/cio/device.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/s390/cio/device.c +2 -0
@@ -488,7 +488,9 @@ {/* Do device recognition, if needed. */ if (cdev->private->state ==DEV_STATE_BOXED ) { +spin_lock_irq (cdev->ccwlock);ccw_device_recognition (cdev); +spin_unlock_irq (cdev->ccwlock);wait_event (cdev->private->wait_q, cdev->private->flags.recog_done);if (cdev->private->state !=DEV_STATE_OFFLINE )
PATCH 35/52 cio: dont panic in non-fatal conditions
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
Remove the call to BUG() for situations which are unexpected but do not cause actual problems.
---
drivers/s390/cio/device_fsm.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-)
drivers/s390/cio/device_fsm.c +6 -19
@@ -1055,14 +1055,14 @@ccw_device_start_id (cdev,0 ); } -static void -ccw_device_offline_irq (struct ccw_device *cdev,enum dev_event dev_event) +static void ccw_device_disabled_irq (struct ccw_device *cdev, +enum dev_event dev_event) {struct subchannel *sch; sch =to_subchannel (cdev->dev.parent);/* -* An interrupt in state offline means a previous disable was not +* An interrupt in a disabled state means a previous disable was not * successful - should not happen, but we try to disable again. */ cio_disable_subchannel (sch);
@@ -1125,25 +1125,12 @@ }/* -* Bug operation action. -*/ -static void -ccw_device_bug (struct ccw_device *cdev,enum dev_event dev_event) -{ -CIO_MSG_EVENT (0 ,"Internal state [%i][%i] not handled for device " -"0.%x.%04x\n" , cdev->private->state, dev_event, - cdev->private->dev_id.ssid, - cdev->private->dev_id.devno); -BUG (); -} - -/* * device statemachine */ fsm_func_t *dev_jumptable[NR_DEV_STATES ][NR_DEV_EVENTS ] = { [DEV_STATE_NOT_OPER ] = { [DEV_EVENT_NOTOPER ] = ccw_device_nop, - [DEV_EVENT_INTERRUPT ] = ccw_device_bug, + [DEV_EVENT_INTERRUPT ] = ccw_device_disabled_irq, [DEV_EVENT_TIMEOUT ] = ccw_device_nop, [DEV_EVENT_VERIFY ] = ccw_device_nop, },
@@ -1161,7 +1148,7 @@ }, [DEV_STATE_OFFLINE] = { [DEV_EVENT_NOTOPER] = ccw_device_generic_notoper, - [DEV_EVENT_INTERRUPT] = ccw_device_offline_irq, + [DEV_EVENT_INTERRUPT] = ccw_device_disabled_irq, [DEV_EVENT_TIMEOUT] = ccw_device_nop, [DEV_EVENT_VERIFY] = ccw_device_offline_verify, },
@@ -1218,7 +1205,7 @@ [DEV_STATE_DISCONNECTED] = { [DEV_EVENT_NOTOPER] = ccw_device_nop, [DEV_EVENT_INTERRUPT] = ccw_device_start_id, - [DEV_EVENT_TIMEOUT] = ccw_device_bug, + [DEV_EVENT_TIMEOUT] = ccw_device_nop, [DEV_EVENT_VERIFY] = ccw_device_start_id, }, [DEV_STATE_DISCONNECTED_SENSE_ID] = {
PATCH 36/52 cio: consistent infrastructure for internal I/O requests
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
Reduce code duplication by introducing a central infrastructure to perform an internal I/O operation on a CCW device.
---
drivers/s390/cio/Makefile | 2 drivers/s390/cio/ccwreq.c | 327 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/s390/cio/device.h | 8 + drivers/s390/cio/io_sch.h | 50 +++++++ 4 files changed, 386 insertions(+), 1 deletion(-)
drivers/s390/cio/ccwreq.c new file +327 -0
@@ -0,0 +1,327 @@ +/* +* Handling of internal CCW device requests. +* +* Copyright IBM Corp. 2009 +* Author(s): Peter Oberparleiter <[email protected]> +*/ + +#include <linux/types.h> +#include <linux/err.h> +#include <asm/ccwdev.h> +#include <asm/cio.h> + +#include "io_sch.h" +#include "cio.h" +#include "device.h" +#include "cio_debug.h" + +/** +* lpm_adjust - adjust path mask +* @lpm: path mask to adjust +* @mask: mask of available paths +* +* Shift @lpm right until @lpm and @mask have at least one bit in common or +* until @lpm is zero. Return the resulting lpm. +*/ +int lpm_adjust (int lpm,int mask) +{ +while (lpm && ((lpm & mask) ==0 )) + lpm >>=1 ; +return lpm; +} + +/* +* Adjust path mask to use next path and reset retry count. Return resulting +* path mask. +*/ +static u16 ccwreq_next_path (struct ccw_device *cdev) +{ +struct ccw_request *req = &cdev->private->req; + + req->retries = req->maxretries; + req->mask =lpm_adjust (req->mask >>=1 , req->lpm); + +return req->mask; +} + +/* +* Clean up device state and report to callback. +*/ +static void ccwreq_stop (struct ccw_device *cdev,int rc) +{ +struct subchannel *sch =to_subchannel (cdev->dev.parent); +struct ccw_request *req = &cdev->private->req; + +if (req->done) +return ; + req->done =1 ; +ccw_device_set_timeout (cdev,0 ); +memset (&cdev->private->irb,0 ,sizeof (struct irb )); + sch->lpm = sch->schib.pmcw.pam; +if (rc && rc != -ENODEV && req->drc) + rc = req->drc; + req->callback (cdev, req->data, rc); +} + +/* +* (Re-)Start the operation until retries and paths are exhausted. +*/ +static void ccwreq_do (struct ccw_device *cdev) +{ +struct ccw_request *req = &cdev->private->req; +struct subchannel *sch =to_subchannel (cdev->dev.parent); +struct ccw1 *cp = req->cp; +int rc = -EACCES ; + +while (req->mask) { +if (req->retries-- ==0 ) { +/* Retries exhausted, try next path. */ +ccwreq_next_path (cdev); +continue ; + } +/* Perform start function. */ + sch->lpm =0xff ; +memset (&cdev->private->irb,0 ,sizeof (struct irb )); + rc =cio_start (sch, cp, req->mask); +if (rc ==0 ) { +/* I/O started successfully. */ +ccw_device_set_timeout (cdev, req->timeout); +return ; + } +if (rc == -ENODEV ) { +/* Permanent device error. */ +break ; + } +if (rc == -EACCES ) { +/* Permant path error. */ +ccwreq_next_path (cdev); +continue ; + } +/* Temporary improper status. */ + rc =cio_clear (sch); +if (rc) +break ; +return ; + } +ccwreq_stop (cdev, rc); +} + +/** +* ccw_request_start - perform I/O request +* @cdev: ccw device +* +* Perform the I/O request specified by cdev->req. +*/ +void ccw_request_start (struct ccw_device *cdev) +{ +struct ccw_request *req = &cdev->private->req; + + req->mask =0x80 ; + req->retries = req->maxretries; + req->mask =lpm_adjust (req->mask, req->lpm); + req->drc =0 ; + req->done =0 ; + req->cancel =0 ; +if (!req->mask) + goto out_nopath; +ccwreq_do (cdev); +return ; + +out_nopath: +ccwreq_stop (cdev, -EACCES ); +} + +/** +* ccw_request_cancel - cancel running I/O request +* @cdev: ccw device +* +* Cancel the I/O request specified by cdev->req. Return non-zero if request +* has already finished, zero otherwise. +*/ +int ccw_request_cancel (struct ccw_device *cdev) +{ +struct subchannel *sch =to_subchannel (cdev->dev.parent); +struct ccw_request *req = &cdev->private->req; +int rc; + +if (req->done) +return 1 ; + req->cancel =1 ; + rc =cio_clear (sch); +if (rc) +ccwreq_stop (cdev, rc); +return 0 ; +} + +/* +* Return the status of the internal I/O started on the specified ccw device. +* Perform BASIC SENSE if required. +*/ +static enum io_status ccwreq_status (struct ccw_device *cdev,struct irb *lcirb) +{ +struct irb *irb = &cdev->private->irb; +struct cmd_scsw *scsw = &irb->scsw.cmd; + +/* Perform BASIC SENSE if needed. */ +if (ccw_device_accumulate_and_sense (cdev, lcirb)) +return IO_RUNNING ; +/* Check for halt/clear interrupt. */ +if (scsw->fctl & (SCSW_FCTL_HALT_FUNC |SCSW_FCTL_CLEAR_FUNC )) +return IO_KILLED ; +/* Check for path error. */ +if (scsw->cc ==3 || scsw->pno) +return IO_PATH_ERROR ; +/* Handle BASIC SENSE data. */ +if (irb->esw.esw0.erw.cons) { +CIO_TRACE_EVENT (2 ,"sensedata" ); +CIO_HEX_EVENT (2 , &cdev->private->dev_id, +sizeof (struct ccw_dev_id )); +CIO_HEX_EVENT (2 , &cdev->private->irb.ecw,SENSE_MAX_COUNT ); +/* Check for command reject. */ +if (irb->ecw[0 ] &SNS0_CMD_REJECT ) +return IO_REJECTED ; +/* Assume that unexpected SENSE data implies an error. */ +return IO_STATUS_ERROR ; + } +/* Check for channel errors. */ +if (scsw->cstat !=0 ) +return IO_STATUS_ERROR ; +/* Check for device errors. */ +if (scsw->dstat & ~(DEV_STAT_CHN_END |DEV_STAT_DEV_END )) +return IO_STATUS_ERROR ; +/* Check for final state. */ +if (!(scsw->dstat &DEV_STAT_DEV_END )) +return IO_RUNNING ; +/* Check for other improper status. */ +if (scsw->cc ==1 && (scsw->stctl &SCSW_STCTL_ALERT_STATUS )) +return IO_STATUS_ERROR ; +return IO_DONE ; +} + +/* +* Log ccw request status. +*/ +static void ccwreq_log_status (struct ccw_device *cdev,enum io_status status) +{ +struct ccw_request *req = &cdev->private->req; +struct { +struct ccw_dev_id dev_id; +u16 retries; +u8 lpm; +u8 status; + } __attribute__ ((packed)) data; + data.dev_id = cdev->private->dev_id; + data.retries = req->retries; + data.lpm = req->mask; + data.status = (u8 ) status; +CIO_TRACE_EVENT (2 ,"reqstat" ); +CIO_HEX_EVENT (2 , &data,sizeof (data)); +} + +/** +* ccw_request_handler - interrupt handler for I/O request procedure. +* @cdev: ccw device +* +* Handle interrupt during I/O request procedure. +*/ +void ccw_request_handler (struct ccw_device *cdev) +{ +struct ccw_request *req = &cdev->private->req; +struct irb *irb = (struct irb *) __LC_IRB; +enum io_status status; +int rc = -EOPNOTSUPP ; + +/* Check status of I/O request. */ + status =ccwreq_status (cdev, irb); +if (req->filter) + status = req->filter (cdev, req->data, irb, status); +if (status !=IO_RUNNING ) +ccw_device_set_timeout (cdev,0 ); +if (status !=IO_DONE && status !=IO_RUNNING ) +ccwreq_log_status (cdev, status); +switch (status) { +case IO_DONE : +break ; +case IO_RUNNING : +return ; +case IO_REJECTED : + goto err; +case IO_PATH_ERROR : + goto out_next_path; +case IO_STATUS_ERROR : + goto out_restart; +case IO_KILLED : +/* Check if request was cancelled on purpose. */ +if (req->cancel) { + rc = -EIO ; + goto err; + } + goto out_restart; + } +/* Check back with request initiator. */ +if (!req->check) + goto out; +switch (req->check (cdev, req->data)) { +case 0 : +break ; +case -EAGAIN : + goto out_restart; +case -EACCES : + goto out_next_path; +default : + goto err; + } +out: +ccwreq_stop (cdev,0 ); +return ; + +out_next_path: +/* Try next path and restart I/O. */ +if (!ccwreq_next_path (cdev)) { + rc = -EACCES ; + goto err; + } +out_restart: +/* Restart. */ +ccwreq_do (cdev); +return ; +err: +ccwreq_stop (cdev, rc); +} + + +/** +* ccw_request_timeout - timeout handler for I/O request procedure +* @cdev: ccw device +* +* Handle timeout during I/O request procedure. +*/ +void ccw_request_timeout (struct ccw_device *cdev) +{ +struct subchannel *sch =to_subchannel (cdev->dev.parent); +struct ccw_request *req = &cdev->private->req; +int rc; + +if (!ccwreq_next_path (cdev)) { +/* set the final return code for this request */ + req->drc = -ETIME ; + } + rc =cio_clear (sch); +if (rc) + goto err; +return ; + +err: +ccwreq_stop (cdev, rc); +} + +/** +* ccw_request_notoper - notoper handler for I/O request procedure +* @cdev: ccw device +* +* Handle timeout during I/O request procedure. +*/ +void ccw_request_notoper (struct ccw_device *cdev) +{ +ccwreq_stop (cdev, -ENODEV ); +}
drivers/s390/cio/device.h +8 -0
@@ -98,6 +98,14 @@int ccw_device_accumulate_and_sense (struct ccw_device *,struct irb *);int ccw_device_do_sense (struct ccw_device *,struct irb *); +/* Function prototype for internal request handling. */ +int lpm_adjust (int lpm,int mask); +void ccw_request_start (struct ccw_device *); +int ccw_request_cancel (struct ccw_device *cdev); +void ccw_request_handler (struct ccw_device *cdev); +void ccw_request_timeout (struct ccw_device *cdev); +void ccw_request_notoper (struct ccw_device *cdev); +/* Function prototypes for sense id stuff. */ void ccw_device_sense_id_start (struct ccw_device *);void ccw_device_sense_id_irq (struct ccw_device *,enum dev_event );
drivers/s390/cio/io_sch.h +50 -0
69 lines not on this page · raw message
drivers/s390/cio/Makefile +1 -1
@@ -3,7 +3,7 @@ # obj-y += airq.o blacklist.o chsc.o cio.o css.o chp.o idset.o isc.o \ - fcx.o itcw.o crw.o + fcx.o itcw.o crw.o ccwreq.o ccw_device-objs += device.o device_fsm.o device_ops.o ccw_device-objs += device_id.o device_pgid.o device_status.o obj-y += ccw_device.o cmf.o
PATCH 37/52 cio: use ccw request infrastructure for sense id
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
Use the newly introduced ccw request infrastructure to implement the sense id operation.
---
drivers/s390/cio/device.h | 1 drivers/s390/cio/device_fsm.c | 66 +------ drivers/s390/cio/device_id.c | 371 +++++++++++++++--------------------------- 3 files changed, 152 insertions(+), 286 deletions(-)
drivers/s390/cio/device_fsm.c +17 -49
@@ -229,7 +229,6 @@ sch =to_subchannel (cdev->dev.parent); -ccw_device_set_timeout (cdev,0 );cio_disable_subchannel (sch);/* * Now that we tried recognition, we have performed device selection
@@ -263,22 +262,10 @@ }switch (state) {case DEV_STATE_NOT_OPER : -CIO_MSG_EVENT (2 ,"SenseID : unknown device %04x on " -"subchannel 0.%x.%04x\n" , - cdev->private->dev_id.devno, - sch->schid.ssid, sch->schid.sch_no);break ;case DEV_STATE_OFFLINE :if (!cdev->online) {ccw_device_update_sense_data (cdev); -/* Issue device info message. */ -CIO_MSG_EVENT (4 ,"SenseID : device 0.%x.%04x reports: " -"CU Type/Mod = %04X/%02X, Dev Type/Mod " -"= %04X/%02X\n" , - cdev->private->dev_id.ssid, - cdev->private->dev_id.devno, - cdev->id.cu_type, cdev->id.cu_model, - cdev->id.dev_type, cdev->id.dev_model);break ; } cdev->private->state =DEV_STATE_OFFLINE ;
@@ -293,10 +280,6 @@ }return ;case DEV_STATE_BOXED : -CIO_MSG_EVENT (0 ,"SenseID : boxed device %04x on " -" subchannel 0.%x.%04x\n" , - cdev->private->dev_id.devno, - sch->schid.ssid, sch->schid.sch_no);if (cdev->id.cu_type !=0 ) {/* device was recognized before */ cdev->private->flags.recog_done =1 ; cdev->private->state =DEV_STATE_BOXED ;
@@ -520,27 +503,25 @@ }/* -* Handle timeout in device recognition. +* Handle events for states that use the ccw request infrastructure. */ -static void -ccw_device_recog_timeout (struct ccw_device *cdev,enum dev_event dev_event) +static void ccw_device_request_event (struct ccw_device *cdev,enum dev_event e) { -int ret; - - ret =ccw_device_cancel_halt_clear (cdev); -switch (ret) { -case 0 : -ccw_device_recog_done (cdev,DEV_STATE_BOXED ); +switch (e) { +case DEV_EVENT_NOTOPER : +ccw_request_notoper (cdev);break ; -case -ENODEV : -ccw_device_recog_done (cdev,DEV_STATE_NOT_OPER ); +case DEV_EVENT_INTERRUPT : +ccw_request_handler (cdev); +break ; +case DEV_EVENT_TIMEOUT : +ccw_request_timeout (cdev);break ;default : -ccw_device_set_timeout (cdev,3 *HZ ); +break ; } } -void ccw_device_verify_done (struct ccw_device *cdev,int err) {
@@ -713,15 +694,6 @@ }/* -* Handle not oper event in device recognition. -*/ -static void -ccw_device_recog_notoper (struct ccw_device *cdev,enum dev_event dev_event) -{ -ccw_device_recog_done (cdev,DEV_STATE_NOT_OPER ); -} - -/* * Handle not operational event in non-special state. */ static void ccw_device_generic_notoper(struct ccw_device *cdev,
@@ -1015,10 +987,6 @@if (cio_enable_subchannel (sch, (u32 )(addr_t )sch) !=0 )/* Couldn't enable the subchannel for i/o. Sick device. */ return ; - -/* After 60s the device recognition is considered to have failed. */ -ccw_device_set_timeout (cdev,60 *HZ ); - cdev->private->state =DEV_STATE_DISCONNECTED_SENSE_ID ;ccw_device_sense_id_start (cdev); }
@@ -1141,9 +1109,9 @@ [DEV_EVENT_VERIFY ] = ccw_device_nop, }, [DEV_STATE_SENSE_ID] = { - [DEV_EVENT_NOTOPER ] = ccw_device_recog_notoper, - [DEV_EVENT_INTERRUPT ] = ccw_device_sense_id_irq, - [DEV_EVENT_TIMEOUT ] = ccw_device_recog_timeout, + [DEV_EVENT_NOTOPER ] = ccw_device_request_event, + [DEV_EVENT_INTERRUPT ] = ccw_device_request_event, + [DEV_EVENT_TIMEOUT ] = ccw_device_request_event, [DEV_EVENT_VERIFY ] = ccw_device_nop, }, [DEV_STATE_OFFLINE ] = {
@@ -1209,9 +1177,9 @@ [DEV_EVENT_VERIFY ] = ccw_device_start_id, }, [DEV_STATE_DISCONNECTED_SENSE_ID] = { - [DEV_EVENT_NOTOPER ] = ccw_device_recog_notoper, - [DEV_EVENT_INTERRUPT ] = ccw_device_sense_id_irq, - [DEV_EVENT_TIMEOUT ] = ccw_device_recog_timeout, + [DEV_EVENT_NOTOPER ] = ccw_device_request_event, + [DEV_EVENT_INTERRUPT ] = ccw_device_request_event, + [DEV_EVENT_TIMEOUT ] = ccw_device_request_event, [DEV_EVENT_VERIFY ] = ccw_device_nop, }, [DEV_STATE_CMFCHANGE ] = {
drivers/s390/cio/device.h +0 -1
@@ -108,7 +108,6 @@/* Function prototypes for sense id stuff. */ void ccw_device_sense_id_start (struct ccw_device *); -void ccw_device_sense_id_irq (struct ccw_device *,enum dev_event );void ccw_device_sense_id_done (struct ccw_device *,int );/* Function prototypes for path grouping stuff. */
drivers/s390/cio/device_id.c +135 -236
428 lines not on this page · raw message
PATCH 38/52 cio: use ccw request infrastructure for pgid
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
Use the newly introduced ccw request infrastructure to implement pgid related operations: sense pgid, set pgid and disband pg.
---
drivers/s390/cio/device.c | 3 drivers/s390/cio/device.h | 3 drivers/s390/cio/device_fsm.c | 100 ---- drivers/s390/cio/device_pgid.c | 868 +++++++++++++++++------------------------ drivers/s390/cio/io_sch.h | 5 5 files changed, 379 insertions(+), 600 deletions(-)
drivers/s390/cio/device.c +0 -3
@@ -957,9 +957,6 @@ {memset (&sch->config,0 ,sizeof (sch->config)); sch->config.csense =1 ; -/* Use subchannel mp mode when there is more than 1 installed CHPID. */ -if ((sch->schib.pmcw.pim & (sch->schib.pmcw.pim -1 )) !=0 ) - sch->config.mp =1 ; }static void io_subchannel_init_fields (struct subchannel *sch)
drivers/s390/cio/device_fsm.c +9 -91
168 lines not on this page · raw message
drivers/s390/cio/device.h +0 -3
@@ -112,15 +112,12 @@/* Function prototypes for path grouping stuff. */ void ccw_device_sense_pgid_start (struct ccw_device *); -void ccw_device_sense_pgid_irq (struct ccw_device *,enum dev_event );void ccw_device_sense_pgid_done (struct ccw_device *,int );void ccw_device_verify_start (struct ccw_device *); -void ccw_device_verify_irq (struct ccw_device *,enum dev_event );void ccw_device_verify_done (struct ccw_device *,int );void ccw_device_disband_start (struct ccw_device *); -void ccw_device_disband_irq (struct ccw_device *,enum dev_event );void ccw_device_disband_done (struct ccw_device *,int );int ccw_device_call_handler (struct ccw_device *);
drivers/s390/cio/device_pgid.c +367 -501
961 lines not on this page · raw message
drivers/s390/cio/io_sch.h +3 -2
@@ -149,8 +149,8 @@struct ccw_dev_id dev_id;/* device id */ struct subchannel_id schid;/* subchannel number */ struct ccw_request req;/* internal I/O request */ -u8 imask;/* lpm mask for SNID/SID/SPGID */ -int iretry;/* retry counter SNID/SID/SPGID */ +int iretry; +u8 pgid_valid_mask;/* mask of valid PGIDs */ struct {unsigned int fast:1 ;/* post with "channel end" */ unsigned int repall:1 ;/* report every interrupt status */
@@ -167,6 +167,7 @@ unsigned int fake_irb:1; /* deliver faked irb */ unsigned int intretry:1; /* retry internal operation */ unsigned int resuming:1; /* recognition while resume */ + unsigned int pgid_rdy:1; /* pgids are ready */ } __attribute__((packed)) flags;unsigned long intparm;/* user interruption parameter */ struct qdio_irq *qdio_data;
PATCH 39/52 cio: allow setting not-operational devices offline
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
Accept a request for setting a not-operational device offline. This way, users can remove devices from Linux which would otherwise remain unusable until reboot.
---
drivers/s390/cio/device.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/s390/cio/device.c +4 -5
@@ -529,11 +529,10 @@int force, ret;unsigned long i; -if ((cdev->private->state !=DEV_STATE_OFFLINE && - cdev->private->state !=DEV_STATE_ONLINE && - cdev->private->state !=DEV_STATE_BOXED && - cdev->private->state !=DEV_STATE_DISCONNECTED ) || -atomic_cmpxchg (&cdev->private->onoff,0 ,1 ) !=0 ) +if (!dev_fsm_final_state (cdev) && + cdev->private->state !=DEV_STATE_DISCONNECTED ) +return -EAGAIN ; +if (atomic_cmpxchg (&cdev->private->onoff,0 ,1 ) !=0 )return -EAGAIN ;if (cdev->drv && !try_module_get (cdev->drv->owner)) {
PATCH 40/52 cio: remove intretry flag
In reply to Martin SchwidefskyAfter changing all internal I/O functions to use the newly introduced ccw request infrastructure, retries are handled automatically after a clear operation. Therefore remove the internal retry flag and associated code.
---
drivers/s390/cio/device.c | 58 +++++++++++---------------------------- drivers/s390/cio/device.h | 1 drivers/s390/cio/device_fsm.c | 27 ------------------ drivers/s390/cio/device_ops.c | 3 -- drivers/s390/cio/device_status.c | 3 -- drivers/s390/cio/io_sch.h | 1 6 files changed, 18 insertions(+), 75 deletions(-)
drivers/s390/cio/device.c +17 -41
@@ -1068,36 +1068,6 @@dev_fsm_event (cdev,DEV_EVENT_VERIFY ); } -static int check_for_io_on_path (struct subchannel *sch,int mask) -{ -if (cio_update_schib (sch)) -return 0 ; -if (scsw_actl (&sch->schib.scsw) && sch->schib.pmcw.lpum == mask) -return 1 ; -return 0 ; -} - -static void terminate_internal_io (struct subchannel *sch, -struct ccw_device *cdev) -{ -if (cio_clear (sch)) { -/* Recheck device in case clear failed. */ - sch->lpm =0 ; -if (cdev->online) -dev_fsm_event (cdev,DEV_EVENT_VERIFY ); -else -css_schedule_eval (sch->schid); -return ; - } - cdev->private->state =DEV_STATE_CLEAR_VERIFY ; -/* Request retry of internal operation. */ - cdev->private->flags.intretry =1 ; -/* Call handler. */ -if (cdev->handler) - cdev->handler (cdev, cdev->private->intparm, -ERR_PTR (-EIO )); -} -static void io_subchannel_terminate_path (struct subchannel *sch,u8 mask) {struct ccw_device *cdev;
@@ -1105,18 +1075,24 @@ cdev =sch_get_cdev (sch);if (!cdev)return ; -if (check_for_io_on_path (sch, mask)) { -if (cdev->private->state ==DEV_STATE_ONLINE ) -ccw_device_kill_io (cdev); -else { -terminate_internal_io (sch, cdev); -/* Re-start path verification. */ -dev_fsm_event (cdev,DEV_EVENT_VERIFY ); - } - }else -/* trigger path verification. */ -dev_fsm_event (cdev,DEV_EVENT_VERIFY ); +if (cio_update_schib (sch)) + goto err; +/* Check for I/O on path. */ +if (scsw_actl (&sch->schib.scsw) ==0 || sch->schib.pmcw.lpum != mask) + goto out; +if (cdev->private->state ==DEV_STATE_ONLINE ) { +ccw_device_kill_io (cdev); + goto out; + } +if (cio_clear (sch)) + goto err; +out: +/* Trigger path verification. */ +dev_fsm_event (cdev,DEV_EVENT_VERIFY ); +return ; +err: +dev_fsm_event (cdev,DEV_EVENT_NOTOPER ); } static int io_subchannel_chp_event(struct subchannel *sch,
drivers/s390/cio/device_fsm.c +0 -27
@@ -771,12 +771,6 @@*/ if (scsw_fctl (&irb->scsw) & (SCSW_FCTL_CLEAR_FUNC |SCSW_FCTL_HALT_FUNC )) { -/* Retry Basic Sense if requested. */ -if (cdev->private->flags.intretry) { - cdev->private->flags.intretry =0 ; -ccw_device_do_sense (cdev, irb); -return ; - } cdev->private->flags.dosense =0 ;memset (&cdev->private->irb,0 ,sizeof (struct irb ));ccw_device_accumulate_irb (cdev, irb);
@@ -800,21 +794,6 @@ }static void -ccw_device_clear_verify (struct ccw_device *cdev,enum dev_event dev_event) -{ -struct irb *irb; - - irb = (struct irb *) __LC_IRB; -/* Accumulate status. We don't do basic sense. */ -ccw_device_accumulate_irb (cdev, irb); -/* Remember to clear irb to avoid residuals. */ -memset (&cdev->private->irb,0 ,sizeof (struct irb )); -/* Try to start delayed device verification. */ -ccw_device_online_verify (cdev,0 ); -/* Note: Don't call handler for cio initiated clear! */ -} - -static void ccw_device_killing_irq (struct ccw_device *cdev,enum dev_event dev_event) {struct subchannel *sch;
@@ -1069,12 +1048,6 @@ [DEV_EVENT_VERIFY ] = ccw_device_nop, }, /* states to wait for i/o completion before doing something */ - [DEV_STATE_CLEAR_VERIFY] = { - [DEV_EVENT_NOTOPER ] = ccw_device_generic_notoper, - [DEV_EVENT_INTERRUPT ] = ccw_device_clear_verify, - [DEV_EVENT_TIMEOUT ] = ccw_device_nop, - [DEV_EVENT_VERIFY ] = ccw_device_nop, - }, [DEV_STATE_TIMEOUT_KILL] = { [DEV_EVENT_NOTOPER ] = ccw_device_generic_notoper, [DEV_EVENT_INTERRUPT ] = ccw_device_killing_irq,
drivers/s390/cio/device.h +0 -1
@@ -21,7 +21,6 @@DEV_STATE_DISBAND_PGID ,DEV_STATE_BOXED ,/* states to wait for i/o completion before doing something */ -DEV_STATE_CLEAR_VERIFY ,DEV_STATE_TIMEOUT_KILL , DEV_STATE_QUIESCE,/* special states for devices gone not operational */
drivers/s390/cio/device_ops.c +1 -2
@@ -167,8 +167,7 @@return -EINVAL ;if (cdev->private->state ==DEV_STATE_NOT_OPER )return -ENODEV ; -if (cdev->private->state ==DEV_STATE_VERIFY || - cdev->private->state ==DEV_STATE_CLEAR_VERIFY ) { +if (cdev->private->state ==DEV_STATE_VERIFY ) {/* Remember to fake irb when finished. */ if (!cdev->private->flags.fake_irb) { cdev->private->flags.fake_irb =1 ;
drivers/s390/cio/device_status.c +0 -3
@@ -336,9 +336,6 @@ sense_ccw->count =SENSE_MAX_COUNT ; sense_ccw->flags =CCW_FLAG_SLI ; -/* Reset internal retry indication. */ - cdev->private->flags.intretry =0 ; - rc =cio_start (sch, sense_ccw,0xff );if (rc == -ENODEV || rc == -EACCES )dev_fsm_event (cdev,DEV_EVENT_VERIFY );
drivers/s390/cio/io_sch.h +0 -1
@@ -165,7 +165,6 @@ unsigned int donotify:1; /* call notify function */ unsigned int recog_done:1; /* dev. recog. complete */ unsigned int fake_irb:1; /* deliver faked irb */ - unsigned int intretry:1; /* retry internal operation */ unsigned int resuming:1; /* recognition while resume */ unsigned int pgid_rdy:1; /* pgids are ready */ } __attribute__((packed)) flags;
PATCH 41/52 cio: split PGID settings and status
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
Split setting (driver wants feature enabled) and status (feature setup was successful) for PGID related ccw device features so that setup errors can be detected. Previously, incorrectly handled setup errors could in rare cases lead to erratic I/O behavior and permanently unusuable devices.
---
arch/s390/include/asm/ccwdev.h | 4 ++++ drivers/s390/block/dasd.c | 7 ------- drivers/s390/block/dasd_eckd.c | 12 +++++++++++- drivers/s390/char/tape_core.c | 3 ++- drivers/s390/cio/device_fsm.c | 2 +- drivers/s390/cio/device_ops.c | 27 +++++++++++++++++++++++++++ drivers/s390/cio/device_pgid.c | 33 ++++++++++++++++++++------------- drivers/s390/cio/io_sch.h | 4 +++- 8 files changed, 68 insertions(+), 24 deletions(-)
arch/s390/include/asm/ccwdev.h +4 -0
@@ -142,6 +142,8 @@extern int ccw_device_set_options_mask (struct ccw_device *,unsigned long );extern int ccw_device_set_options (struct ccw_device *,unsigned long );extern void ccw_device_clear_options (struct ccw_device *,unsigned long ); +int ccw_device_is_pathgroup (struct ccw_device *cdev); +int ccw_device_is_multipath (struct ccw_device *cdev);/* Allow for i/o completion notification after primary interrupt status. */ #define CCWDEV_EARLY_NOTIFICATION 0x0001
@@ -151,6 +153,8 @@#define CCWDEV_DO_PATHGROUP 0x0004/* Allow forced onlining of boxed devices. */ #define CCWDEV_ALLOW_FORCE 0x0008 +/* Try to use multipath mode. */ +#define CCWDEV_DO_MULTIPATH 0x0010extern int ccw_device_start (struct ccw_device *,struct ccw1 *,unsigned long ,__u8 ,unsigned long );
drivers/s390/block/dasd.c +0 -7
@@ -2301,13 +2301,6 @@ {int ret; - ret =ccw_device_set_options (cdev,CCWDEV_DO_PATHGROUP ); -if (ret) { -DBF_EVENT (DBF_WARNING , -"dasd_generic_probe: could not set ccw-device options " -"for %s\n" ,dev_name (&cdev->dev)); -return ret; - } ret =dasd_add_sysfs_files (cdev);if (ret) { DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s",
drivers/s390/block/dasd_eckd.c +11 -1
@@ -90,7 +90,8 @@int ret;/* set ECKD specific ccw-device options */ - ret =ccw_device_set_options (cdev,CCWDEV_ALLOW_FORCE ); + ret =ccw_device_set_options (cdev,CCWDEV_ALLOW_FORCE | +CCWDEV_DO_PATHGROUP |CCWDEV_DO_MULTIPATH );if (ret) {DBF_EVENT_DEVID (DBF_WARNING , cdev,"%s" , "dasd_eckd_probe: could not set "
@@ -1090,6 +1091,15 @@struct dasd_block *block;int is_known, rc; +if (!ccw_device_is_pathgroup (device->cdev)) { +dev_warn (&device->cdev->dev, +"A channel path group could not be established\n" ); +return -EIO ; + } +if (!ccw_device_is_multipath (device->cdev)) { +dev_info (&device->cdev->dev, +"The DASD is not operating in multipath mode\n" ); + } private = (struct dasd_eckd_private *) device->private;if (!private) { private =kzalloc (sizeof (*private),GFP_KERNEL |GFP_DMA );
drivers/s390/char/tape_core.c +2 -1
@@ -579,7 +579,8 @@ device =tape_alloc_device ();if (IS_ERR (device))return -ENODEV ; -ccw_device_set_options (cdev,CCWDEV_DO_PATHGROUP ); +ccw_device_set_options (cdev,CCWDEV_DO_PATHGROUP | +CCWDEV_DO_MULTIPATH ); ret =sysfs_create_group (&cdev->dev.kobj, &tape_attr_group);if (ret) {tape_put_device (device);
drivers/s390/cio/device_fsm.c +1 -1
@@ -601,7 +601,7 @@if (cdev->private->state !=DEV_STATE_ONLINE )return -EINVAL ;/* Are we doing path grouping? */ -if (!cdev->private->options.pgroup) { +if (!cdev->private->flags.pgroup) {/* No, set state offline immediately. */ ccw_device_done (cdev,DEV_STATE_OFFLINE );return 0 ;
drivers/s390/cio/device_ops.c +27 -0
@@ -46,6 +46,7 @@ cdev->private->options.repall = (flags &CCWDEV_REPORT_ALL ) !=0 ; cdev->private->options.pgroup = (flags &CCWDEV_DO_PATHGROUP ) !=0 ; cdev->private->options.force = (flags &CCWDEV_ALLOW_FORCE ) !=0 ; + cdev->private->options.mpath = (flags &CCWDEV_DO_MULTIPATH ) !=0 ;return 0 ; }
@@ -74,6 +75,7 @@ cdev->private->options.repall |= (flags &CCWDEV_REPORT_ALL ) !=0 ; cdev->private->options.pgroup |= (flags &CCWDEV_DO_PATHGROUP ) !=0 ; cdev->private->options.force |= (flags &CCWDEV_ALLOW_FORCE ) !=0 ; + cdev->private->options.mpath |= (flags &CCWDEV_DO_MULTIPATH ) !=0 ;return 0 ; }
@@ -90,9 +92,34 @@ cdev->private->options.repall &= (flags &CCWDEV_REPORT_ALL ) ==0 ; cdev->private->options.pgroup &= (flags &CCWDEV_DO_PATHGROUP ) ==0 ; cdev->private->options.force &= (flags &CCWDEV_ALLOW_FORCE ) ==0 ; + cdev->private->options.mpath &= (flags &CCWDEV_DO_MULTIPATH ) ==0 ; }/** +* ccw_device_is_pathgroup - determine if paths to this device are grouped +* @cdev: ccw device +* +* Return non-zero if there is a path group, zero otherwise. +*/ +int ccw_device_is_pathgroup (struct ccw_device *cdev) +{ +return cdev->private->flags.pgroup; +} +EXPORT_SYMBOL (ccw_device_is_pathgroup); + +/** +* ccw_device_is_multipath - determine if device is operating in multipath mode +* @cdev: ccw device +* +* Return non-zero if device is operating in multipath mode, zero otherwise. +*/ +int ccw_device_is_multipath (struct ccw_device *cdev) +{ +return cdev->private->flags.mpath; +} +EXPORT_SYMBOL (ccw_device_is_multipath); + +/** * ccw_device_clear() - terminate I/O request processing * @cdev: target ccw device * @intparm: interruption parameter; value is only used if no I/O is
drivers/s390/cio/device_pgid.c +20 -13
@@ -30,8 +30,8 @@ {struct subchannel *sch =to_subchannel (cdev->dev.parent);struct ccw_dev_id *id = &cdev->private->dev_id; -int mpath = !cdev->private->flags.pgid_single; -int pgroup = cdev->private->options.pgroup; +int mpath = cdev->private->flags.mpath; +int pgroup = cdev->private->flags.pgroup;if (rc) goto out;
@@ -150,7 +150,7 @@ fn =SPID_FUNC_ESTABLISH ; else fn =SPID_FUNC_RESIGN ; -if (!cdev->private->flags.pgid_single) +if (cdev->private->flags.mpath) fn |=SPID_FUNC_MULTI_PATH ;spid_build_cp (cdev, fn);ccw_request_start (cdev);
@@ -177,13 +177,13 @@case -EACCES :break ;case -EOPNOTSUPP : -if (!cdev->private->flags.pgid_single) { +if (cdev->private->flags.mpath) {/* Try without multipathing. */ - cdev->private->flags.pgid_single =1 ; + cdev->private->flags.mpath =0 ; goto out_restart; }/* Try without pathgrouping. */ - cdev->private->options.pgroup =0 ; + cdev->private->flags.pgroup =0 ; goto out_restart;default : goto err;
@@ -374,7 +374,7 @@ req->timeout =PGID_TIMEOUT ; req->maxretries =PGID_RETRIES ; req->lpm =0x80 ; -if (cdev->private->options.pgroup) { +if (cdev->private->flags.pgroup) { req->callback = spid_callback;spid_do (cdev); }else {
@@ -400,10 +400,17 @@CIO_HEX_EVENT (4 , &cdev->private->dev_id,sizeof (cdev->private->dev_id));if (!cdev->private->flags.pgid_rdy) {/* No pathgrouping possible. */ - cdev->private->options.pgroup =0 ; - cdev->private->flags.pgid_single =1 ; - }else - cdev->private->flags.pgid_single =0 ; + cdev->private->flags.pgroup =0 ; + cdev->private->flags.mpath =0 ; + }else { +/* +* Initialize pathgroup and multipath state with target values. +* They may change in the course of path verification. +*/ + cdev->private->flags.pgroup = cdev->private->options.pgroup; + cdev->private->flags.mpath = cdev->private->options.mpath; + + } cdev->private->flags.doverify =0 ;verify_start (cdev); }
@@ -419,7 +426,7 @@if (rc) goto out;/* Ensure consistent multipathing state at device and channel. */ - cdev->private->flags.pgid_single =1 ; + cdev->private->flags.mpath =0 ;if (sch->config.mp) { sch->config.mp =0 ; rc =cio_commit_config (sch);
@@ -453,7 +460,7 @@ req->lpm = sch->schib.pmcw.pam & sch->opm; req->callback = disband_callback; fn =SPID_FUNC_DISBAND ; -if (!cdev->private->flags.pgid_single) +if (cdev->private->flags.mpath) fn |=SPID_FUNC_MULTI_PATH ;spid_build_cp (cdev, fn);ccw_request_start (cdev);
drivers/s390/cio/io_sch.h +3 -1
@@ -156,9 +156,9 @@ unsigned int repall:1; /* report every interrupt status */ unsigned int pgroup:1; /* do path grouping */ unsigned int force:1; /* allow forced online */ + unsigned int mpath:1; /* do multipathing */ } __attribute__ ((packed)) options;struct { -unsigned int pgid_single:1 ;/* use single path for Set PGID */ unsigned int esid:1 ;/* Ext. SenseID supported by HW */ unsigned int dosense:1 ;/* delayed SENSE required */ unsigned int doverify:1 ;/* delayed path verification */
@@ -167,6 +167,8 @@ unsigned int fake_irb:1; /* deliver faked irb */ unsigned int resuming:1; /* recognition while resume */ unsigned int pgid_rdy:1; /* pgids are ready */ + unsigned int pgroup:1; /* pathgroup is set up */ + unsigned int mpath:1; /* multipathing is set up */ } __attribute__((packed)) flags;unsigned long intparm;/* user interruption parameter */ struct qdio_irq *qdio_data;
PATCH 42/52 cio: use sense-pgid operation for path verification
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
Set-pgid operations fail for some device types under z/VM for which the hypervisor has already set the pgid. Also reserved devices or changed pgids are not correctly recognized. Fix these problems by using a combination of sense-pgid and set-pgid and by also accepting pre-defined pgid settings.
---
drivers/s390/cio/device.h | 3 drivers/s390/cio/device_fsm.c | 41 +---------- drivers/s390/cio/device_pgid.c | 148 ++++++++++++++++++++++++++--------------- drivers/s390/cio/io_sch.h | 1 4 files changed, 99 insertions(+), 94 deletions(-)
drivers/s390/cio/device_fsm.c +4 -37
@@ -395,33 +395,6 @@ }/* -* Function called from device_pgid.c after sense path ground has completed. -*/ -void -ccw_device_sense_pgid_done (struct ccw_device *cdev,int err) -{ -struct subchannel *sch; - - sch =to_subchannel (cdev->dev.parent); -switch (err) { -case -EOPNOTSUPP :/* path grouping not supported, use nop instead. */ -case 0 :/* success */ -case -EACCES :/* partial success, some paths not operational */ -break ; -case -ETIME :/* Sense path group id stopped by timeout. */ -case -EUSERS :/* device is reserved for someone else. */ -ccw_device_done (cdev,DEV_STATE_BOXED ); -return ; -default : -ccw_device_done (cdev,DEV_STATE_NOT_OPER ); -return ; - } -/* Start Path Group verification. */ - cdev->private->state =DEV_STATE_VERIFY ; -ccw_device_verify_start (cdev); -} - -/* * Start device recognition. */ void ccw_device_recognition (struct ccw_device *cdev)
@@ -503,6 +476,7 @@ }break ;case -ETIME : +case -EUSERS :/* Reset oper notify indication after verify error. */ cdev->private->flags.donotify =0 ;ccw_device_done (cdev,DEV_STATE_BOXED );
@@ -540,16 +514,9 @@dev_fsm_event (cdev,DEV_EVENT_NOTOPER );return ret; } -/* Do we want to do path grouping? */ -if (!cdev->private->options.pgroup) { -/* Start initial path verification. */ - cdev->private->state =DEV_STATE_VERIFY ; -ccw_device_verify_start (cdev); -return 0 ; - } -/* Do a SensePGID first. */ - cdev->private->state =DEV_STATE_SENSE_PGID ; -ccw_device_sense_pgid_start (cdev); +/* Start initial path verification. */ + cdev->private->state =DEV_STATE_VERIFY ; +ccw_device_verify_start (cdev);return 0 ; }
drivers/s390/cio/device.h +0 -3
@@ -110,9 +110,6 @@void ccw_device_sense_id_done (struct ccw_device *,int );/* Function prototypes for path grouping stuff. */ -void ccw_device_sense_pgid_start (struct ccw_device *); -void ccw_device_sense_pgid_done (struct ccw_device *,int ); -void ccw_device_verify_start (struct ccw_device *);void ccw_device_verify_done (struct ccw_device *,int );
drivers/s390/cio/device_pgid.c +95 -53
206 lines not on this page · raw message
drivers/s390/cio/io_sch.h +0 -1
@@ -166,7 +166,6 @@ unsigned int recog_done:1; /* dev. recog. complete */ unsigned int fake_irb:1; /* deliver faked irb */ unsigned int resuming:1; /* recognition while resume */ - unsigned int pgid_rdy:1; /* pgids are ready */ unsigned int pgroup:1; /* pathgroup is set up */ unsigned int mpath:1; /* multipathing is set up */ } __attribute__((packed)) flags;
PATCH 43/52 cio: make steal lock procedure more robust
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
An Unconditional Reserve + Release operation (steal lock) for a boxed device may fail when encountering special error cases (e.g. unit checks or path errors). Fix this by using the more robust ccw_request infrastructure for performing the steal lock CCW program.
---
drivers/s390/cio/device.h | 4 + drivers/s390/cio/device_fsm.c | 55 +++++++++----------- drivers/s390/cio/device_ops.c | 112 +++++++++++++++++++---------------------- drivers/s390/cio/device_pgid.c | 52 +++++++++++++++++++ 4 files changed, 134 insertions(+), 89 deletions(-)
drivers/s390/cio/device_fsm.c +26 -29
@@ -641,6 +641,23 @@ }/* +* Handle path verification event in boxed state. +*/ +static void ccw_device_boxed_verify (struct ccw_device *cdev, +enum dev_event dev_event) +{ +struct subchannel *sch =to_subchannel (cdev->dev.parent); + +if (cdev->online) { +if (cio_enable_subchannel (sch, (u32 ) (addr_t ) sch)) +ccw_device_done (cdev,DEV_STATE_NOT_OPER ); +else +ccw_device_online_verify (cdev, dev_event); + }else +css_schedule_eval (sch->schid); +} + +/* * Got an interrupt for a normal io (state online). */ static void
@@ -817,32 +834,6 @@ }static void -ccw_device_stlck_done (struct ccw_device *cdev,enum dev_event dev_event) -{ -struct irb *irb; - -switch (dev_event) { -case DEV_EVENT_INTERRUPT : - irb = (struct irb *) __LC_IRB; -/* Check for unsolicited interrupt. */ -if ((scsw_stctl (&irb->scsw) == - (SCSW_STCTL_STATUS_PEND |SCSW_STCTL_ALERT_STATUS )) && - (!scsw_cc (&irb->scsw))) -/* FIXME: we should restart stlck here, but this -* is extremely unlikely ... */ - goto out_wakeup; - -ccw_device_accumulate_irb (cdev, irb); -/* We don't care about basic sense etc. */ -break ; -default :/* timeout */ -break ; - } -out_wakeup: -wake_up (&cdev->private->wait_q); -} - -static void ccw_device_start_id (struct ccw_device *cdev,enum dev_event dev_event) {struct subchannel *sch;
@@ -1010,9 +1001,9 @@ }, [DEV_STATE_BOXED] = { [DEV_EVENT_NOTOPER] = ccw_device_generic_notoper, - [DEV_EVENT_INTERRUPT] = ccw_device_stlck_done, - [DEV_EVENT_TIMEOUT] = ccw_device_stlck_done, - [DEV_EVENT_VERIFY] = ccw_device_nop, + [DEV_EVENT_INTERRUPT] = ccw_device_nop, + [DEV_EVENT_TIMEOUT] = ccw_device_nop, + [DEV_EVENT_VERIFY] = ccw_device_boxed_verify, }, /* states to wait for i/o completion before doing something */ [DEV_STATE_TIMEOUT_KILL] = {
@@ -1052,6 +1043,12 @@ [DEV_EVENT_TIMEOUT] = ccw_device_update_cmfblock, [DEV_EVENT_VERIFY] = ccw_device_update_cmfblock, }, + [DEV_STATE_STEAL_LOCK] = { + [DEV_EVENT_NOTOPER] = ccw_device_request_event, + [DEV_EVENT_INTERRUPT] = ccw_device_request_event, + [DEV_EVENT_TIMEOUT] = ccw_device_request_event, + [DEV_EVENT_VERIFY] = ccw_device_nop, + }, };EXPORT_SYMBOL_GPL (ccw_device_set_timeout);
drivers/s390/cio/device.h +4 -0
@@ -28,6 +28,7 @@DEV_STATE_DISCONNECTED_SENSE_ID ,DEV_STATE_CMFCHANGE ,DEV_STATE_CMFUPDATE , +DEV_STATE_STEAL_LOCK ,/* last element! */ NR_DEV_STATES };
@@ -116,6 +117,9 @@void ccw_device_disband_start (struct ccw_device *);void ccw_device_disband_done (struct ccw_device *,int ); +void ccw_device_stlck_start (struct ccw_device *,void *,void *,void *); +void ccw_device_stlck_done (struct ccw_device *,void *,int ); +int ccw_device_call_handler (struct ccw_device *);int ccw_device_stlck (struct ccw_device *);
drivers/s390/cio/device_ops.c +52 -60
132 lines not on this page · raw message
drivers/s390/cio/device_pgid.c +52 -0
55 lines not on this page · raw message
PATCH 44/52 cio: remove registered flag from ccw_device_private
In reply to Martin SchwidefskyFrom: Sebastian Ott <[email protected]>
We used to maintain a "registered" flag in our ccw_device_private structure. This patch removes the "registered" flag and converts all users of it to device_is_registered which has the exact same meaning.
Note: The usage the atomic operation test_and_clear_bit is replaced by the non-atomic if (device_is_registered()) device_del(). This will not do harm, since we serialize calls to ccw_device_unregister with a single-threaded workqueue.
---
drivers/s390/cio/device.c | 11 +++-------- drivers/s390/cio/io_sch.h | 1 - 2 files changed, 3 insertions(+), 9 deletions(-)
drivers/s390/cio/device.c +3 -8
@@ -303,7 +303,7 @@static void ccw_device_unregister (struct ccw_device *cdev) { -if (test_and_clear_bit (1 , &cdev->private->registered)) { +if (device_is_registered (&cdev->dev)) {device_del (&cdev->dev);/* Release reference from device_initialize(). */ put_device (&cdev->dev);
@@ -640,12 +640,7 @@ cdev->private->dev_id.devno);if (ret)return ret; - ret =device_add (dev); -if (ret) -return ret; - -set_bit (1 , &cdev->private->registered); -return ret; +return device_add (dev); }static int match_dev_id (struct device *dev,void *data)
@@ -669,7 +664,7 @@ {int ret; -if (test_bit (1 , &cdev->private->registered)) { +if (device_is_registered (&cdev->dev)) {device_release_driver (&cdev->dev); ret =device_attach (&cdev->dev);WARN_ON (ret == -ENODEV );
drivers/s390/cio/io_sch.h +0 -1
@@ -145,7 +145,6 @@struct subchannel *sch;int state;/* device state */ atomic_t onoff; -unsigned long registered;struct ccw_dev_id dev_id;/* device id */ struct subchannel_id schid;/* subchannel number */ struct ccw_request req;/* internal I/O request */
PATCH 45/52 cio: add per device initialization status flag
In reply to Martin SchwidefskyFrom: Sebastian Ott <[email protected]>
The function ccw_device_unregister has to ensure to remove all references obtained by device_add and device_initialize. Unfortunately it gets called for devices which are
1) uninitialized, 2) initialized but unregistered, and
3) registered devices. To distinguish 1) and 2) this patch introduces a new flag "initialized", which is 1 as long as we hold the initial device reference.
---
drivers/s390/cio/device.c | 6 ++++++ drivers/s390/cio/io_sch.h | 1 + 2 files changed, 7 insertions(+)
drivers/s390/cio/device.c +6 -0
@@ -304,7 +304,11 @@static void ccw_device_unregister (struct ccw_device *cdev) {if (device_is_registered (&cdev->dev)) { +/* Undo device_add(). */ device_del (&cdev->dev); + } +if (cdev->private->flags.initialized) { + cdev->private->flags.initialized =0 ;/* Release reference from device_initialize(). */ put_device (&cdev->dev); }
@@ -716,6 +720,7 @@put_device (&cdev->dev);return -ENODEV ; } + cdev->private->flags.initialized =1 ;return 0 ; }
@@ -998,6 +1003,7 @@ cdev =sch_get_cdev (sch); cdev->dev.groups = ccwdev_attr_groups;device_initialize (&cdev->dev); + cdev->private->flags.initialized =1 ;ccw_device_register (cdev);/* * Check if the device is already online. If it is
drivers/s390/cio/io_sch.h +1 -0
@@ -167,6 +167,7 @@ unsigned int resuming:1; /* recognition while resume */ unsigned int pgroup:1; /* pathgroup is set up */ unsigned int mpath:1; /* multipathing is set up */ + unsigned int initialized:1; /* set if initial reference held */ } __attribute__((packed)) flags;unsigned long intparm;/* user interruption parameter */ struct qdio_irq *qdio_data;
PATCH 46/52 cio: fix quiesce state
In reply to Martin SchwidefskyFrom: Sebastian Ott <[email protected]>
DEV_STATE_QUIESCE is used to stop all IO on a busy subchannel. This patch fixes the following problems related to the QUIESCE state:
* Fix a potential race condition which could occur when the resulting state was DEV_STATE_OFFLINE.
* Add missing locking around cio_disable_subchannel, ccw_device_cancel_halt_clear and the cdev's handler.
* Loop until we know for sure that the subchannel is disabled.
---
drivers/s390/cio/device.c | 35 +++++++++++++++++++---------------- drivers/s390/cio/device_fsm.c | 17 ++++------------- 2 files changed, 23 insertions(+), 29 deletions(-)
drivers/s390/cio/device.c +19 -16
@@ -1130,33 +1130,36 @@return 0 ; } -static void -io_subchannel_shutdown (struct subchannel *sch) +static void io_subchannel_shutdown (struct subchannel *sch) {struct ccw_device *cdev;int ret; +spin_lock_irq (sch->lock); cdev =sch_get_cdev (sch); -if (cio_is_console (sch->schid)) -return ; + goto out_unlock;if (!sch->schib.pmcw.ena) -/* Nothing to do. */ -return ; + goto out_unlock; ret =cio_disable_subchannel (sch);if (ret != -EBUSY ) -/* Subchannel is disabled, we're done. */ -return ; - cdev->private->state =DEV_STATE_QUIESCE ; + goto out_unlock;if (cdev->handler) - cdev->handler (cdev, cdev->private->intparm, -ERR_PTR (-EIO )); - ret =ccw_device_cancel_halt_clear (cdev); -if (ret == -EBUSY ) { -ccw_device_set_timeout (cdev,HZ /10 ); -wait_event (cdev->private->wait_q,dev_fsm_final_state (cdev)); + cdev->handler (cdev, cdev->private->intparm,ERR_PTR (-EIO )); +while (ret == -EBUSY ) { + cdev->private->state =DEV_STATE_QUIESCE ; + ret =ccw_device_cancel_halt_clear (cdev); +if (ret == -EBUSY ) { +ccw_device_set_timeout (cdev,HZ /10 ); +spin_unlock_irq (sch->lock); +wait_event (cdev->private->wait_q, + cdev->private->state !=DEV_STATE_QUIESCE ); +spin_lock_irq (sch->lock); + } + ret =cio_disable_subchannel (sch); } -cio_disable_subchannel (sch); +out_unlock: +spin_unlock_irq (sch->lock); }static int device_is_disconnected (struct ccw_device *cdev)
drivers/s390/cio/device_fsm.c +4 -13
@@ -911,10 +911,7 @@ ccw_device_quiesce_done(struct ccw_device *cdev, enum dev_event dev_event) { ccw_device_set_timeout(cdev, 0); -if (dev_event ==DEV_EVENT_NOTOPER ) - cdev->private->state =DEV_STATE_NOT_OPER ; -else - cdev->private->state =DEV_STATE_OFFLINE ; + cdev->private->state =DEV_STATE_NOT_OPER ;wake_up (&cdev->private->wait_q); }
@@ -924,17 +921,11 @@int ret; ret =ccw_device_cancel_halt_clear (cdev); -switch (ret) { -case 0 : - cdev->private->state =DEV_STATE_OFFLINE ; -wake_up (&cdev->private->wait_q); -break ; -case -ENODEV : +if (ret == -EBUSY ) { +ccw_device_set_timeout (cdev,HZ /10 ); + }else { cdev->private->state =DEV_STATE_NOT_OPER ;wake_up (&cdev->private->wait_q); -break ; -default : -ccw_device_set_timeout (cdev,HZ /10 ); } }
PATCH 47/52 cio: handle failed disable_subchannel after device recognition
In reply to Martin SchwidefskyFrom: Sebastian Ott <[email protected]>
Handle a failing cio_disable_subchannel at the end of our device recognition as if the recognition itself failed. This way subsequent registration steps do not need to handle enabled subchannels.
---
drivers/s390/cio/device_fsm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/s390/cio/device_fsm.c +2 -1
@@ -229,7 +229,8 @@ sch =to_subchannel (cdev->dev.parent); -cio_disable_subchannel (sch); +if (cio_disable_subchannel (sch)) + state =DEV_STATE_NOT_OPER ;/* * Now that we tried recognition, we have performed device selection * through ssch() and the path information is up to date.
PATCH 48/52 cio: handle busy subchannel in ccw_device_move_to_sch
In reply to Martin SchwidefskyFrom: Sebastian Ott <[email protected]>
Try to disable the old subchannel before we ask the driver core to move the attached device to a new parent. This way we can use the QUIESCE state during shutdown which prevents a possible use after free situation in some error cases.
---
drivers/s390/cio/device.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
drivers/s390/cio/device.c +22 -2
@@ -892,12 +892,27 @@ struct subchannel *sch) {struct subchannel *old_sch; -int rc; +int rc, old_enabled =0 ; old_sch =to_subchannel (cdev->dev.parent);/* Obtain child reference for new parent. */ if (!get_device (&sch->dev))return -ENODEV ; + +if (!sch_is_pseudo_sch (old_sch)) { +spin_lock_irq (old_sch->lock); + old_enabled = old_sch->schib.pmcw.ena; + rc =0 ; +if (old_enabled) + rc =cio_disable_subchannel (old_sch); +spin_unlock_irq (old_sch->lock); +if (rc == -EBUSY ) { +/* Release child reference for new parent. */ +put_device (&sch->dev); +return rc; + } + } +mutex_lock (&sch->reg_mutex); rc =device_move (&cdev->dev, &sch->dev,DPM_ORDER_PARENT_BEFORE_DEV );mutex_unlock (&sch->reg_mutex);
@@ -906,6 +921,12 @@ cdev->private->dev_id.ssid, cdev->private->dev_id.devno, sch->schid.ssid, sch->schib.pmcw.dev, rc); +if (old_enabled) { +/* Try to reenable the old subchannel. */ +spin_lock_irq (old_sch->lock); +cio_enable_subchannel (old_sch, (u32 )(addr_t )old_sch); +spin_unlock_irq (old_sch->lock); + }/* Release child reference for new parent. */ put_device (&sch->dev);return rc;
@@ -914,7 +935,6 @@if (!sch_is_pseudo_sch (old_sch)) {spin_lock_irq (old_sch->lock);sch_set_cdev (old_sch,NULL ); -cio_disable_subchannel (old_sch);spin_unlock_irq (old_sch->lock);css_schedule_eval (old_sch->schid); }
PATCH 49/52 cio: quiesce subchannel in io_subchannel_remove
In reply to Martin SchwidefskyFrom: Sebastian Ott <[email protected]>
Ensure that there will be no more interrupts for an unregistered device by using the same quiesce and disable loop as in io_subchannel_shutdown.
---
drivers/s390/cio/device.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/s390/cio/device.c +9 -1
@@ -1059,6 +1059,8 @@return 0 ; } +static void io_subchannel_quiesce (struct subchannel *); +static int io_subchannel_remove (struct subchannel *sch) {
@@ -1068,6 +1070,7 @@ cdev =sch_get_cdev (sch);if (!cdev) goto out_free; +io_subchannel_quiesce (sch);/* Set ccw device to not operational and drop reference. */ spin_lock_irqsave (cdev->ccwlock, flags);sch_set_cdev (sch,NULL );
@@ -1150,7 +1153,7 @@return 0 ; } -static void io_subchannel_shutdown (struct subchannel *sch) +static void io_subchannel_quiesce (struct subchannel *sch) {struct ccw_device *cdev;int ret;
@@ -1182,6 +1185,11 @@spin_unlock_irq (sch->lock); } +static void io_subchannel_shutdown (struct subchannel *sch) +{ +io_subchannel_quiesce (sch); +} +static int device_is_disconnected (struct ccw_device *cdev) {if (!cdev)
PATCH 50/52 cio: change locking in io_subchannel_remove
In reply to Martin SchwidefskyFrom: Sebastian Ott <[email protected]>
IO subchannels are always unregistered in process context, so use spin_lock_irq in the corresponding remove callback.
---
drivers/s390/cio/device.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/s390/cio/device.c +2 -3
@@ -1065,17 +1065,16 @@ io_subchannel_remove (struct subchannel *sch) {struct ccw_device *cdev; -unsigned long flags; cdev =sch_get_cdev (sch);if (!cdev) goto out_free;io_subchannel_quiesce (sch);/* Set ccw device to not operational and drop reference. */ -spin_lock_irqsave (cdev->ccwlock, flags); +spin_lock_irq (cdev->ccwlock);sch_set_cdev (sch,NULL ); cdev->private->state =DEV_STATE_NOT_OPER ; -spin_unlock_irqrestore (cdev->ccwlock, flags); +spin_unlock_irq (cdev->ccwlock);ccw_device_unregister (cdev); out_free:kfree (sch->private);
PATCH 51/52 cio: improve error recovery for internal I/Os
In reply to Martin SchwidefskyFrom: Peter Oberparleiter <[email protected]>
Improve error recovery for internal I/Os by repeating each I/O 256 times per path to cope with long-running non-permanent error conditions. Also retry each path twice to cope with link flapping, i.e. single paths becoming unavailable in the order in which they are tried.
---
drivers/s390/cio/ccwreq.c | 7 ++++--- drivers/s390/cio/device_id.c | 2 +- drivers/s390/cio/device_pgid.c | 2 +- drivers/s390/cio/io_sch.h | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-)
drivers/s390/cio/ccwreq.c +4 -3
@@ -82,7 +82,7 @@/* Perform start function. */ sch->lpm =0xff ;memset (&cdev->private->irb,0 ,sizeof (struct irb )); - rc =cio_start (sch, cp, req->mask); + rc =cio_start (sch, cp, (u8 ) req->mask);if (rc ==0 ) {/* I/O started successfully. */ ccw_device_set_timeout (cdev, req->timeout);
@@ -116,7 +116,8 @@ {struct ccw_request *req = &cdev->private->req; - req->mask =0x80 ; +/* Try all paths twice to counter link flapping. */ + req->mask =0x8080 ; req->retries = req->maxretries; req->mask =lpm_adjust (req->mask, req->lpm); req->drc =0 ;
@@ -212,7 +213,7 @@ } __attribute__ ((packed)) data; data.dev_id = cdev->private->dev_id; data.retries = req->retries; - data.lpm = req->mask; + data.lpm = (u8 ) req->mask; data.status = (u8 ) status;CIO_TRACE_EVENT (2 ,"reqstat" );CIO_HEX_EVENT (2 , &data,sizeof (data));
drivers/s390/cio/device_id.c +1 -1
@@ -21,7 +21,7 @@#include "device.h" #include "io_sch.h" -#define SENSE_ID_RETRIES 5 +#define SENSE_ID_RETRIES 256#define SENSE_ID_TIMEOUT (10 * HZ)#define SENSE_ID_MIN_LEN 4#define SENSE_ID_BASIC_LEN 7
drivers/s390/cio/device_pgid.c +1 -1
@@ -20,7 +20,7 @@#include "device.h" #include "io_sch.h" -#define PGID_RETRIES 5 +#define PGID_RETRIES 256#define PGID_TIMEOUT (10 * HZ)/*
drivers/s390/cio/io_sch.h +1 -1
@@ -109,7 +109,7 @@void (*callback)(struct ccw_device *,void *,int );void *data;/* These fields are used internally. */ -u8 mask; +u16 mask;u16 retries;int drc; int cancel:1;
PATCH 52/52 cio: dont unregister a busy device in ccw_device_set_offline
In reply to Martin SchwidefskyFrom: Sebastian Ott <[email protected]>
If we detect a busy subchannel after the driver's set_offline callback returned in ccw_device_set_offline, the current behavior is to unregister the device, which may lead to undesired consequences. Change this to just quiesce the subchannel and go on with the offline processing.
Note: This is no excuse for not fixing these drivers - after the set_offline callback they should have no running IO!
---
drivers/s390/cio/device.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
drivers/s390/cio/device.c +20 -9
@@ -314,6 +314,8 @@ } } +static void io_subchannel_quiesce (struct subchannel *); +/** * ccw_device_set_offline() - disable a ccw device for I/O * @cdev: target ccw device
@@ -327,7 +329,8 @@*/ int ccw_device_set_offline (struct ccw_device *cdev) { -int ret; +struct subchannel *sch; +int ret, state;if (!cdev)return -ENODEV ;
@@ -341,6 +344,7 @@ } cdev->online =0 ;spin_lock_irq (cdev->ccwlock); + sch =to_subchannel (cdev->dev.parent);/* Wait until a final state or DISCONNECTED is reached */ while (!dev_fsm_final_state (cdev) && cdev->private->state !=DEV_STATE_DISCONNECTED ) {
@@ -349,9 +353,21 @@ cdev->private->state == DEV_STATE_DISCONNECTED));spin_lock_irq (cdev->ccwlock); } - ret =ccw_device_offline (cdev); -if (ret) - goto error; +do { + ret =ccw_device_offline (cdev); +if (!ret) +break ; +CIO_MSG_EVENT (0 ,"ccw_device_offline returned %d, device " +"0.%x.%04x\n" , ret, cdev->private->dev_id.ssid, + cdev->private->dev_id.devno); +if (ret != -EBUSY ) + goto error; + state = cdev->private->state; +spin_unlock_irq (cdev->ccwlock); +io_subchannel_quiesce (sch); +spin_lock_irq (cdev->ccwlock); + cdev->private->state = state; + }while (ret == -EBUSY );spin_unlock_irq (cdev->ccwlock);wait_event (cdev->private->wait_q, (dev_fsm_final_state (cdev) || cdev->private->state ==DEV_STATE_DISCONNECTED ));
@@ -368,9 +384,6 @@return 0 ; error: -CIO_MSG_EVENT (0 ,"ccw_device_offline returned %d, device 0.%x.%04x\n" , - ret, cdev->private->dev_id.ssid, - cdev->private->dev_id.devno); cdev->private->state =DEV_STATE_OFFLINE ;dev_fsm_event (cdev,DEV_EVENT_NOTOPER );spin_unlock_irq (cdev->ccwlock);
@@ -1059,8 +1072,6 @@return 0 ; } -static void io_subchannel_quiesce (struct subchannel *); -static int io_subchannel_remove (struct subchannel *sch) {
I have one pending for the tty3270 driver, will resend.
Arnd <><
s390: move keyboard compat ioctls into tty3270 driver
All keyboard ioctls are compatible, so we can simply move the compat handling into the vt and tty3270 drivers.
drivers/s390/char/tty3270.c +19 -0
@@ -1731,6 +1731,22 @@ tty3270_ioctl(struct tty_struct *tty, struct file *file,return kbd_ioctl (tp->kbd, file, cmd, arg); } +#ifdef CONFIG_COMPAT +static long +tty3270_compat_ioctl (struct tty_struct *tty,struct file *file, +unsigned int cmd,unsigned long arg) +{ +struct tty3270 *tp; + + tp = tty->driver_data; +if (!tp) +return -ENODEV ; +if (tty->flags & (1 <<TTY_IO_ERROR )) +return -EIO ; +return kbd_ioctl (tp->kbd, file, cmd, (unsigned long )compat_ptr (arg)); +} +#endif +static const struct tty_operations tty3270_ops = { .open = tty3270_open, .close = tty3270_close,
@@ -1745,6 +1761,9 @@ static const struct tty_operations tty3270_ops = { .hangup = tty3270_hangup, .wait_until_sent = tty3270_wait_until_sent, .ioctl = tty3270_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = tty3270_compat_ioctl, +#endif .set_termios = tty3270_set_termios };
Re: s390: move keyboard compat ioctls into tty3270 driver
Quoted 4 lines · On Fri, 13 Nov 2009 16:31:17 +0100 Arnd Bergmann <[email protected]> wrote:
All keyboard ioctls are compatible, so we can simply move the compat handling into the vt and tty3270 drivers.
Signed-off-by Arnd Bergmann <[email protected]>
I'll add the patch to the queue. Thanks ..
Signature · 4 lines
blue skies, Martin. "Reality continues to ruin my life." - Calvin.