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

Configure Feed

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

Merge tag 's390-7.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux

Pull s390 updates from Heiko Carstens:

- Drop support for outdated 3590/3592 and 3480 tape devices, and limit
support to virtualized 3490E types devices

- Implement exception based WARN() and WARN_ONCE() similar to x86

- Slightly optimize preempt primitives like __preempt_count_add() and
__preempt_count_dec_and_test()

- A couple of small fixes and improvements

* tag 's390-7.0-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: (35 commits)
s390/tape: Consolidate tape config options and modules
s390/cio: Fix device lifecycle handling in css_alloc_subchannel()
s390/tape: Rename tape_34xx.c to tape_3490.c
s390/tape: Cleanup sense data analysis and error handling
s390/tape: Remove 3480 tape device type
s390/tape: Remove unused command definitions
s390/tape: Remove special block id handling
s390/tape: Remove tape load display support
s390/tape: Remove support for 3590/3592 models
s390/kexec: Emit an error message when cmdline is too long
s390/configs: Enable BLK_DEV_NULL_BLK as module
s390: Document s390 stackprotector support
s390/perf: Disable register readout on sampling events
s390/Kconfig: Define non-zero ILLEGAL_POINTER_VALUE
s390/bug: Prevent tail-call optimization
s390/bug: Skip __WARN_trap() in call traces
s390/bug: Implement WARN_ONCE()
s390/bug: Implement __WARN_printf()
s390/traps: Copy monitor code to pt_regs
s390/bug: Introduce and use monitor code macro
...

+1158 -3310
+4
Documentation/arch/s390/mm.rst
··· 109 109 | KASAN shadow | KASAN untracked 110 110 | | 111 111 +------------------+ ASCE limit 112 + | | 113 + | CONFIG_ILLEGAL_POINTER_VALUE causes memory access fault 114 + | | 115 + +------------------+
+1 -1
Documentation/features/debug/stackprotector/arch-support.txt
··· 21 21 | parisc: | TODO | 22 22 | powerpc: | ok | 23 23 | riscv: | ok | 24 - | s390: | TODO | 24 + | s390: | ok | 25 25 | sh: | ok | 26 26 | sparc: | TODO | 27 27 | um: | TODO |
+19
arch/s390/Kconfig
··· 69 69 Clang versions before 19.1.0 do not support A, 70 70 O, and R inline assembly format flags. 71 71 72 + config CC_HAS_ASM_IMMEDIATE_STRINGS 73 + def_bool !(CC_IS_GCC && GCC_VERSION < 90000) 74 + help 75 + GCC versions before 9.0.0 cannot handle strings as immediate 76 + input operands in inline assemblies. 77 + 72 78 config CC_HAS_STACKPROTECTOR_GLOBAL 73 79 def_bool $(cc-option, -mstack-protector-guard=global -mstack-protector-guard-record) 74 80 ··· 91 85 select ARCH_ENABLE_MEMORY_HOTREMOVE 92 86 select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2 93 87 select ARCH_ENABLE_THP_MIGRATION if TRANSPARENT_HUGEPAGE 88 + select ARCH_HAS_CC_CAN_LINK 94 89 select ARCH_HAS_CPU_FINALIZE_INIT 95 90 select ARCH_HAS_CURRENT_STACK_POINTER 96 91 select ARCH_HAS_DEBUG_VIRTUAL ··· 300 293 default 5 301 294 302 295 source "kernel/livepatch/Kconfig" 296 + 297 + config ARCH_CC_CAN_LINK 298 + bool 299 + default $(cc_can_link_user,-m64) 300 + 301 + config ARCH_USERFLAGS 302 + string 303 + default "-m64" 303 304 304 305 config ARCH_SUPPORTS_KEXEC 305 306 def_bool y ··· 718 703 719 704 config ARCH_SPARSEMEM_DEFAULT 720 705 def_bool y 706 + 707 + config ILLEGAL_POINTER_VALUE 708 + hex 709 + default 0xdead000000000000 721 710 722 711 config MAX_PHYSMEM_BITS 723 712 int "Maximum size of supported physical memory in bits (42-53)"
+1
arch/s390/boot/Makefile
··· 21 21 KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_MARCH),$(KBUILD_CFLAGS_DECOMPRESSOR)) 22 22 KBUILD_AFLAGS += $(CC_FLAGS_MARCH_MINIMUM) -D__DISABLE_EXPORTS 23 23 KBUILD_CFLAGS += $(CC_FLAGS_MARCH_MINIMUM) -D__DISABLE_EXPORTS 24 + KBUILD_CFLAGS += $(call cc-option, -Wno-default-const-init-unsafe) 24 25 25 26 CFLAGS_sclp_early_core.o += -I$(srctree)/drivers/s390/char 26 27
+1
arch/s390/boot/startup.c
··· 336 336 BUILD_BUG_ON(!IS_ALIGNED(TEXT_OFFSET, THREAD_SIZE)); 337 337 BUILD_BUG_ON(!IS_ALIGNED(__NO_KASLR_START_KERNEL, THREAD_SIZE)); 338 338 BUILD_BUG_ON(__NO_KASLR_END_KERNEL > _REGION1_SIZE); 339 + BUILD_BUG_ON(CONFIG_ILLEGAL_POINTER_VALUE < _REGION1_SIZE); 339 340 vsize = get_vmem_size(ident_map_size, vmemmap_size, vmalloc_size, _REGION3_SIZE); 340 341 boot_debug("vmem size estimated: 0x%016lx\n", vsize); 341 342 if (IS_ENABLED(CONFIG_KASAN) || __NO_KASLR_END_KERNEL > _REGION2_SIZE ||
+1
arch/s390/configs/debug_defconfig
··· 446 446 CONFIG_VIRTIO_BLK=y 447 447 CONFIG_BLK_DEV_RBD=m 448 448 CONFIG_BLK_DEV_NVME=m 449 + CONFIG_BLK_DEV_NULL_BLK=m 449 450 CONFIG_ENCLOSURE_SERVICES=m 450 451 CONFIG_GENWQE=m 451 452 CONFIG_RAID_ATTRS=m
+1
arch/s390/configs/defconfig
··· 436 436 CONFIG_VIRTIO_BLK=y 437 437 CONFIG_BLK_DEV_RBD=m 438 438 CONFIG_BLK_DEV_NVME=m 439 + CONFIG_BLK_DEV_NULL_BLK=m 439 440 CONFIG_ENCLOSURE_SERVICES=m 440 441 CONFIG_GENWQE=m 441 442 CONFIG_RAID_ATTRS=m
+1 -1
arch/s390/include/asm/ap.h
··· 78 78 }; 79 79 80 80 /** 81 - * ap_intructions_available() - Test if AP instructions are available. 81 + * ap_instructions_available() - Test if AP instructions are available. 82 82 * 83 83 * Returns true if the AP instructions are installed, otherwise false. 84 84 */
+1
arch/s390/include/asm/asm-prototypes.h
··· 3 3 4 4 #include <linux/kvm_host.h> 5 5 #include <linux/ftrace.h> 6 + #include <asm/bug.h> 6 7 #include <asm/fpu.h> 7 8 #include <asm/nospec-branch.h> 8 9 #include <asm-generic/asm-prototypes.h>
+1 -1
arch/s390/include/asm/asm.h
··· 30 30 */ 31 31 #if defined(__GCC_ASM_FLAG_OUTPUTS__) && !(IS_ENABLED(CONFIG_CC_ASM_FLAG_OUTPUT_BROKEN)) 32 32 33 - #define __HAVE_ASM_FLAG_OUTPUTS__ 33 + #define __HAVE_ASM_FLAG_OUTPUTS__ 1 34 34 35 35 #define CC_IPM(sym) 36 36 #define CC_OUT(sym, var) "=@cc" (var)
+106 -39
arch/s390/include/asm/bug.h
··· 2 2 #ifndef _ASM_S390_BUG_H 3 3 #define _ASM_S390_BUG_H 4 4 5 - #include <linux/stringify.h> 5 + #include <linux/compiler.h> 6 + #include <linux/const.h> 6 7 7 - #ifdef CONFIG_BUG 8 + #define MONCODE_BUG _AC(0, U) 9 + #define MONCODE_BUG_ARG _AC(1, U) 8 10 9 - #ifndef CONFIG_DEBUG_BUGVERBOSE 10 - #define _BUGVERBOSE_LOCATION(file, line) 11 + #ifndef __ASSEMBLER__ 12 + #if defined(CONFIG_BUG) && defined(CONFIG_CC_HAS_ASM_IMMEDIATE_STRINGS) 13 + 14 + #ifdef CONFIG_DEBUG_BUGVERBOSE 15 + #define __BUG_ENTRY_VERBOSE(format, file, line) \ 16 + " .long " format " - . # bug_entry::format\n" \ 17 + " .long " file " - . # bug_entry::file\n" \ 18 + " .short " line " # bug_entry::line\n" 11 19 #else 12 - #define __BUGVERBOSE_LOCATION(file, line) \ 13 - .pushsection .rodata.str, "aMS", @progbits, 1; \ 14 - .align 2; \ 15 - 10002: .ascii file "\0"; \ 16 - .popsection; \ 17 - \ 18 - .long 10002b - .; \ 19 - .short line; 20 - #define _BUGVERBOSE_LOCATION(file, line) __BUGVERBOSE_LOCATION(file, line) 20 + #define __BUG_ENTRY_VERBOSE(format, file, line) 21 21 #endif 22 22 23 - #ifndef CONFIG_GENERIC_BUG 24 - #define __BUG_ENTRY(cond_str, flags) 23 + #ifdef CONFIG_DEBUG_BUGVERBOSE_DETAILED 24 + #define WARN_CONDITION_STR(cond_str) cond_str 25 25 #else 26 - #define __BUG_ENTRY(cond_str, flags) \ 27 - .pushsection __bug_table, "aw"; \ 28 - .align 4; \ 29 - 10000: .long 10001f - .; \ 30 - _BUGVERBOSE_LOCATION(WARN_CONDITION_STR(cond_str) __FILE__, __LINE__) \ 31 - .short flags; \ 32 - .popsection; \ 33 - 10001: 26 + #define WARN_CONDITION_STR(cond_str) "" 34 27 #endif 35 28 36 - #define ASM_BUG_FLAGS(cond_str, flags) \ 37 - __BUG_ENTRY(cond_str, flags) \ 38 - mc 0,0 29 + #define __BUG_ENTRY(format, file, line, flags, size) \ 30 + " .section __bug_table,\"aw\"\n" \ 31 + "1: .long 0b - . # bug_entry::bug_addr\n" \ 32 + __BUG_ENTRY_VERBOSE(format, file, line) \ 33 + " .short "flags" # bug_entry::flags\n" \ 34 + " .org 1b+"size"\n" \ 35 + " .previous" 39 36 40 - #define ASM_BUG() ASM_BUG_FLAGS("", 0) 41 - 42 - #define __BUG_FLAGS(cond_str, flags) \ 43 - asm_inline volatile(__stringify(ASM_BUG_FLAGS(cond_str, flags))); 44 - 45 - #define __WARN_FLAGS(cond_str, flags) \ 46 - do { \ 47 - __BUG_FLAGS(cond_str, BUGFLAG_WARNING|(flags)); \ 37 + #define __BUG_ASM(cond_str, flags) \ 38 + do { \ 39 + asm_inline volatile("\n" \ 40 + "0: mc %[monc](%%r0),0\n" \ 41 + __BUG_ENTRY("%[frmt]", "%[file]", "%[line]", \ 42 + "%[flgs]", "%[size]") \ 43 + : \ 44 + : [monc] "i" (MONCODE_BUG), \ 45 + [frmt] "i" (WARN_CONDITION_STR(cond_str)), \ 46 + [file] "i" (__FILE__), \ 47 + [line] "i" (__LINE__), \ 48 + [flgs] "i" (flags), \ 49 + [size] "i" (sizeof(struct bug_entry))); \ 48 50 } while (0) 49 51 50 - #define BUG() \ 51 - do { \ 52 - __BUG_FLAGS("", 0); \ 53 - unreachable(); \ 52 + #define BUG() \ 53 + do { \ 54 + __BUG_ASM("", 0); \ 55 + unreachable(); \ 54 56 } while (0) 57 + 58 + #define __WARN_FLAGS(cond_str, flags) \ 59 + do { \ 60 + __BUG_ASM(cond_str, BUGFLAG_WARNING | (flags)); \ 61 + } while (0) 62 + 63 + #define __WARN_bug_entry(flags, format) \ 64 + ({ \ 65 + struct bug_entry *bug; \ 66 + \ 67 + asm_inline volatile("\n" \ 68 + "0: larl %[bug],1f\n" \ 69 + __BUG_ENTRY("%[frmt]", "%[file]", "%[line]", \ 70 + "%[flgs]", "%[size]") \ 71 + : [bug] "=d" (bug) \ 72 + : [frmt] "i" (format), \ 73 + [file] "i" (__FILE__), \ 74 + [line] "i" (__LINE__), \ 75 + [flgs] "i" (flags), \ 76 + [size] "i" (sizeof(struct bug_entry))); \ 77 + bug; \ 78 + }) 79 + 80 + /* 81 + * Variable Argument List (va_list) as defined in ELF Application 82 + * Binary Interface s390x Supplement documentation. 83 + */ 84 + struct arch_va_list { 85 + long __gpr; 86 + long __fpr; 87 + void *__overflow_arg_area; 88 + void *__reg_save_area; 89 + }; 90 + 91 + struct bug_entry; 92 + struct pt_regs; 93 + 94 + void *__warn_args(struct arch_va_list *args, struct pt_regs *regs); 95 + void __WARN_trap(struct bug_entry *bug, ...); 96 + 97 + #define __WARN_print_arg(flags, format, arg...) \ 98 + do { \ 99 + int __flags = (flags) | BUGFLAG_WARNING | BUGFLAG_ARGS; \ 100 + \ 101 + __WARN_trap(__WARN_bug_entry(__flags, format), ## arg); \ 102 + /* prevent tail-call optimization */ \ 103 + asm(""); \ 104 + } while (0) 105 + 106 + #define __WARN_printf(taint, fmt, arg...) \ 107 + __WARN_print_arg(BUGFLAG_TAINT(taint), fmt, ## arg) 108 + 109 + #define WARN_ONCE(cond, format, arg...) \ 110 + ({ \ 111 + int __ret_warn_on = !!(cond); \ 112 + \ 113 + if (unlikely(__ret_warn_on)) { \ 114 + __WARN_print_arg(BUGFLAG_ONCE|BUGFLAG_TAINT(TAINT_WARN),\ 115 + format, ## arg); \ 116 + } \ 117 + __ret_warn_on; \ 118 + }) 55 119 56 120 #define HAVE_ARCH_BUG 121 + #define HAVE_ARCH_BUG_FORMAT 122 + #define HAVE_ARCH_BUG_FORMAT_ARGS 57 123 58 - #endif /* CONFIG_BUG */ 124 + #endif /* CONFIG_BUG && CONFIG_CC_HAS_ASM_IMMEDIATE_STRINGS */ 125 + #endif /* __ASSEMBLER__ */ 59 126 60 127 #include <asm-generic/bug.h> 61 128
+1
arch/s390/include/asm/pci_io.h
··· 18 18 #define ZPCI_IOMAP_SHIFT 48 19 19 #define ZPCI_IOMAP_ADDR_SHIFT 62 20 20 #define ZPCI_IOMAP_ADDR_BASE (1UL << ZPCI_IOMAP_ADDR_SHIFT) 21 + #define ZPCI_IOMAP_ADDR_MAX ((1UL << (ZPCI_IOMAP_ADDR_SHIFT + 1)) - 1) 21 22 #define ZPCI_IOMAP_ADDR_OFF_MASK ((1UL << ZPCI_IOMAP_SHIFT) - 1) 22 23 #define ZPCI_IOMAP_MAX_ENTRIES \ 23 24 (1UL << (ZPCI_IOMAP_ADDR_SHIFT - ZPCI_IOMAP_SHIFT))
+44 -3
arch/s390/include/asm/preempt.h
··· 8 8 #include <asm/cmpxchg.h> 9 9 #include <asm/march.h> 10 10 11 - /* We use the MSB mostly because its available */ 11 + /* 12 + * Use MSB so it is possible to read preempt_count with LLGT which 13 + * reads the least significant 31 bits with a single instruction. 14 + */ 12 15 #define PREEMPT_NEED_RESCHED 0x80000000 13 16 14 17 /* ··· 26 23 */ 27 24 static __always_inline int preempt_count(void) 28 25 { 29 - return READ_ONCE(get_lowcore()->preempt_count) & ~PREEMPT_NEED_RESCHED; 26 + unsigned long lc_preempt, count; 27 + 28 + BUILD_BUG_ON(sizeof_field(struct lowcore, preempt_count) != sizeof(int)); 29 + lc_preempt = offsetof(struct lowcore, preempt_count); 30 + /* READ_ONCE(get_lowcore()->preempt_count) & ~PREEMPT_NEED_RESCHED */ 31 + asm_inline( 32 + ALTERNATIVE("llgt %[count],%[offzero](%%r0)\n", 33 + "llgt %[count],%[offalt](%%r0)\n", 34 + ALT_FEATURE(MFEATURE_LOWCORE)) 35 + : [count] "=d" (count) 36 + : [offzero] "i" (lc_preempt), 37 + [offalt] "i" (lc_preempt + LOWCORE_ALT_ADDRESS), 38 + "m" (((struct lowcore *)0)->preempt_count)); 39 + return count; 30 40 } 31 41 32 42 static __always_inline void preempt_count_set(int pc) ··· 84 68 */ 85 69 if (!IS_ENABLED(CONFIG_PROFILE_ALL_BRANCHES)) { 86 70 if (__builtin_constant_p(val) && (val >= -128) && (val <= 127)) { 87 - __atomic_add_const(val, &get_lowcore()->preempt_count); 71 + unsigned long lc_preempt; 72 + 73 + lc_preempt = offsetof(struct lowcore, preempt_count); 74 + asm_inline( 75 + ALTERNATIVE("asi %[offzero](%%r0),%[val]\n", 76 + "asi %[offalt](%%r0),%[val]\n", 77 + ALT_FEATURE(MFEATURE_LOWCORE)) 78 + : "+m" (((struct lowcore *)0)->preempt_count) 79 + : [offzero] "i" (lc_preempt), [val] "i" (val), 80 + [offalt] "i" (lc_preempt + LOWCORE_ALT_ADDRESS) 81 + : "cc"); 88 82 return; 89 83 } 90 84 } ··· 113 87 */ 114 88 static __always_inline bool __preempt_count_dec_and_test(void) 115 89 { 90 + #ifdef __HAVE_ASM_FLAG_OUTPUTS__ 91 + unsigned long lc_preempt; 92 + int cc; 93 + 94 + lc_preempt = offsetof(struct lowcore, preempt_count); 95 + asm_inline( 96 + ALTERNATIVE("alsi %[offzero](%%r0),%[val]\n", 97 + "alsi %[offalt](%%r0),%[val]\n", 98 + ALT_FEATURE(MFEATURE_LOWCORE)) 99 + : "=@cc" (cc), "+m" (((struct lowcore *)0)->preempt_count) 100 + : [offzero] "i" (lc_preempt), [val] "i" (-1), 101 + [offalt] "i" (lc_preempt + LOWCORE_ALT_ADDRESS)); 102 + return (cc == 0) || (cc == 2); 103 + #else 116 104 return __atomic_add_const_and_test(-1, &get_lowcore()->preempt_count); 105 + #endif 117 106 } 118 107 119 108 /*
+30 -12
arch/s390/include/asm/ptrace.h
··· 120 120 unsigned long gprs[NUM_GPRS]; 121 121 }; 122 122 }; 123 - unsigned long orig_gpr2; 123 + union { 124 + unsigned long orig_gpr2; 125 + unsigned long monitor_code; 126 + }; 124 127 union { 125 128 struct { 126 129 unsigned int int_code; ··· 217 214 #define arch_has_single_step() (1) 218 215 #define arch_has_block_step() (1) 219 216 220 - #define user_mode(regs) (((regs)->psw.mask & PSW_MASK_PSTATE) != 0) 221 - #define instruction_pointer(regs) ((regs)->psw.addr) 222 - #define user_stack_pointer(regs)((regs)->gprs[15]) 223 217 #define profile_pc(regs) instruction_pointer(regs) 224 218 225 - static inline long regs_return_value(struct pt_regs *regs) 219 + static __always_inline bool user_mode(const struct pt_regs *regs) 220 + { 221 + return psw_bits(regs->psw).pstate; 222 + } 223 + 224 + static inline long regs_return_value(const struct pt_regs *regs) 226 225 { 227 226 return regs->gprs[2]; 227 + } 228 + 229 + static __always_inline unsigned long instruction_pointer(const struct pt_regs *regs) 230 + { 231 + return regs->psw.addr; 228 232 } 229 233 230 234 static inline void instruction_pointer_set(struct pt_regs *regs, ··· 243 233 int regs_query_register_offset(const char *name); 244 234 const char *regs_query_register_name(unsigned int offset); 245 235 246 - static __always_inline unsigned long kernel_stack_pointer(struct pt_regs *regs) 236 + static __always_inline unsigned long kernel_stack_pointer(const struct pt_regs *regs) 247 237 { 248 238 return regs->gprs[15]; 249 239 } 250 240 251 - static __always_inline unsigned long regs_get_register(struct pt_regs *regs, unsigned int offset) 241 + static __always_inline unsigned long user_stack_pointer(const struct pt_regs *regs) 242 + { 243 + return regs->gprs[15]; 244 + } 245 + 246 + static __always_inline unsigned long regs_get_register(const struct pt_regs *regs, 247 + unsigned int offset) 252 248 { 253 249 if (offset >= NUM_GPRS) 254 250 return 0; 255 251 return regs->gprs[offset]; 256 252 } 257 253 258 - static __always_inline int regs_within_kernel_stack(struct pt_regs *regs, unsigned long addr) 254 + static __always_inline int regs_within_kernel_stack(const struct pt_regs *regs, 255 + unsigned long addr) 259 256 { 260 257 unsigned long ksp = kernel_stack_pointer(regs); 261 258 ··· 278 261 * is specifined by @regs. If the @n th entry is NOT in the kernel stack, 279 262 * this returns 0. 280 263 */ 281 - static __always_inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs, unsigned int n) 264 + static __always_inline unsigned long regs_get_kernel_stack_nth(const struct pt_regs *regs, 265 + unsigned int n) 282 266 { 283 267 unsigned long addr; 284 268 ··· 296 278 * 297 279 * regs_get_kernel_argument() returns @n th argument of the function call. 298 280 */ 299 - static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs, 300 - unsigned int n) 281 + static __always_inline unsigned long regs_get_kernel_argument(const struct pt_regs *regs, 282 + unsigned int n) 301 283 { 302 284 unsigned int argoffset = STACK_FRAME_OVERHEAD / sizeof(long); 303 285 ··· 308 290 return regs_get_kernel_stack_nth(regs, argoffset + n); 309 291 } 310 292 311 - static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc) 293 + static __always_inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc) 312 294 { 313 295 regs->gprs[2] = rc; 314 296 }
-103
arch/s390/include/uapi/asm/tape390.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 - /************************************************************************* 3 - * 4 - * enables user programs to display messages and control encryption 5 - * on s390 tape devices 6 - * 7 - * Copyright IBM Corp. 2001, 2006 8 - * Author(s): Michael Holzheu <holzheu@de.ibm.com> 9 - * 10 - *************************************************************************/ 11 - 12 - #ifndef _TAPE390_H 13 - #define _TAPE390_H 14 - 15 - #define TAPE390_DISPLAY _IOW('d', 1, struct display_struct) 16 - 17 - /* 18 - * The TAPE390_DISPLAY ioctl calls the Load Display command 19 - * which transfers 17 bytes of data from the channel to the subsystem: 20 - * - 1 format control byte, and 21 - * - two 8-byte messages 22 - * 23 - * Format control byte: 24 - * 0-2: New Message Overlay 25 - * 3: Alternate Messages 26 - * 4: Blink Message 27 - * 5: Display Low/High Message 28 - * 6: Reserved 29 - * 7: Automatic Load Request 30 - * 31 - */ 32 - 33 - typedef struct display_struct { 34 - char cntrl; 35 - char message1[8]; 36 - char message2[8]; 37 - } display_struct; 38 - 39 - /* 40 - * Tape encryption support 41 - */ 42 - 43 - struct tape390_crypt_info { 44 - char capability; 45 - char status; 46 - char medium_status; 47 - } __attribute__ ((packed)); 48 - 49 - 50 - /* Macros for "capable" field */ 51 - #define TAPE390_CRYPT_SUPPORTED_MASK 0x01 52 - #define TAPE390_CRYPT_SUPPORTED(x) \ 53 - ((x.capability & TAPE390_CRYPT_SUPPORTED_MASK)) 54 - 55 - /* Macros for "status" field */ 56 - #define TAPE390_CRYPT_ON_MASK 0x01 57 - #define TAPE390_CRYPT_ON(x) (((x.status) & TAPE390_CRYPT_ON_MASK)) 58 - 59 - /* Macros for "medium status" field */ 60 - #define TAPE390_MEDIUM_LOADED_MASK 0x01 61 - #define TAPE390_MEDIUM_ENCRYPTED_MASK 0x02 62 - #define TAPE390_MEDIUM_ENCRYPTED(x) \ 63 - (((x.medium_status) & TAPE390_MEDIUM_ENCRYPTED_MASK)) 64 - #define TAPE390_MEDIUM_LOADED(x) \ 65 - (((x.medium_status) & TAPE390_MEDIUM_LOADED_MASK)) 66 - 67 - /* 68 - * The TAPE390_CRYPT_SET ioctl is used to switch on/off encryption. 69 - * The "encryption_capable" and "tape_status" fields are ignored for this ioctl! 70 - */ 71 - #define TAPE390_CRYPT_SET _IOW('d', 2, struct tape390_crypt_info) 72 - 73 - /* 74 - * The TAPE390_CRYPT_QUERY ioctl is used to query the encryption state. 75 - */ 76 - #define TAPE390_CRYPT_QUERY _IOR('d', 3, struct tape390_crypt_info) 77 - 78 - /* Values for "kekl1/2_type" and "kekl1/2_type_on_tape" fields */ 79 - #define TAPE390_KEKL_TYPE_NONE 0 80 - #define TAPE390_KEKL_TYPE_LABEL 1 81 - #define TAPE390_KEKL_TYPE_HASH 2 82 - 83 - struct tape390_kekl { 84 - unsigned char type; 85 - unsigned char type_on_tape; 86 - char label[65]; 87 - } __attribute__ ((packed)); 88 - 89 - struct tape390_kekl_pair { 90 - struct tape390_kekl kekl[2]; 91 - } __attribute__ ((packed)); 92 - 93 - /* 94 - * The TAPE390_KEKL_SET ioctl is used to set Key Encrypting Key labels. 95 - */ 96 - #define TAPE390_KEKL_SET _IOW('d', 4, struct tape390_kekl_pair) 97 - 98 - /* 99 - * The TAPE390_KEKL_QUERY ioctl is used to query Key Encrypting Key labels. 100 - */ 101 - #define TAPE390_KEKL_QUERY _IOR('d', 5, struct tape390_kekl_pair) 102 - 103 - #endif
+11
arch/s390/kernel/entry.S
··· 23 23 #include <asm/unistd.h> 24 24 #include <asm/page.h> 25 25 #include <asm/sigp.h> 26 + #include <asm/bug.h> 26 27 #include <asm/irq.h> 27 28 #include <asm/fpu-insn.h> 28 29 #include <asm/setup.h> ··· 173 172 lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task 174 173 BR_EX %r14 175 174 SYM_FUNC_END(__switch_to_asm) 175 + 176 + #if defined(CONFIG_BUG) && defined(CONFIG_CC_HAS_ASM_IMMEDIATE_STRINGS) 177 + 178 + SYM_FUNC_START(__WARN_trap) 179 + mc MONCODE_BUG_ARG(%r0),0 180 + BR_EX %r14 181 + SYM_FUNC_END(__WARN_trap) 182 + EXPORT_SYMBOL(__WARN_trap) 183 + 184 + #endif /* CONFIG_BUG && CONFIG_CC_HAS_ASM_IMMEDIATE_STRINGS */ 176 185 177 186 #if IS_ENABLED(CONFIG_KVM) 178 187 /*
+3 -1
arch/s390/kernel/machine_kexec_file.c
··· 270 270 if (image->kernel_buf_len < minsize + max_command_line_size) 271 271 goto out; 272 272 273 - if (image->cmdline_buf_len >= max_command_line_size) 273 + if (image->cmdline_buf_len >= max_command_line_size) { 274 + pr_err("Kernel command line exceeds supported limit of %lu", max_command_line_size); 274 275 goto out; 276 + } 275 277 276 278 memcpy(data.parm->command_line, image->cmdline_buf, 277 279 image->cmdline_buf_len);
+1 -1
arch/s390/kernel/perf_cpum_sf.c
··· 841 841 u64 sample_type = event->attr.sample_type; 842 842 843 843 return sample_type & (PERF_SAMPLE_CALLCHAIN | PERF_SAMPLE_REGS_USER | 844 - PERF_SAMPLE_STACK_USER); 844 + PERF_SAMPLE_REGS_INTR | PERF_SAMPLE_STACK_USER); 845 845 } 846 846 847 847 static int cpumsf_pmu_event_init(struct perf_event *event)
+43 -3
arch/s390/kernel/traps.c
··· 23 23 #include <linux/cpu.h> 24 24 #include <linux/entry-common.h> 25 25 #include <linux/kmsan.h> 26 + #include <linux/bug.h> 26 27 #include <asm/asm-extable.h> 27 28 #include <asm/irqflags.h> 28 29 #include <asm/ptrace.h> ··· 221 220 do_trap(regs, SIGILL, ILL_PRVOPC, "space switch event"); 222 221 } 223 222 223 + #if defined(CONFIG_BUG) && defined(CONFIG_CC_HAS_ASM_IMMEDIATE_STRINGS) 224 + 225 + void *__warn_args(struct arch_va_list *args, struct pt_regs *regs) 226 + { 227 + struct stack_frame *stack_frame; 228 + 229 + /* 230 + * Generate va_list from pt_regs. See ELF Application Binary Interface 231 + * s390x Supplement documentation for details. 232 + * 233 + * - __overflow_arg_area needs to point to the parameter area, which 234 + * is right above the standard stack frame (160 bytes) 235 + * 236 + * - __reg_save_area needs to point to a register save area where 237 + * general registers (%r2 - %r6) can be found at offset 16. Which 238 + * means that the gprs save area of pt_regs can be used 239 + * 240 + * - __gpr must be set to one, since the first parameter has been 241 + * processed (pointer to bug_entry) 242 + */ 243 + stack_frame = (struct stack_frame *)regs->gprs[15]; 244 + args->__overflow_arg_area = stack_frame + 1; 245 + args->__reg_save_area = regs->gprs; 246 + args->__gpr = 1; 247 + return args; 248 + } 249 + 250 + #endif /* CONFIG_BUG && CONFIG_CC_HAS_ASM_IMMEDIATE_STRINGS */ 251 + 224 252 static void monitor_event_exception(struct pt_regs *regs) 225 253 { 254 + enum bug_trap_type btt; 255 + 226 256 if (user_mode(regs)) 227 257 return; 228 - switch (report_bug(regs->psw.addr - (regs->int_code >> 16), regs)) { 258 + if (regs->monitor_code == MONCODE_BUG_ARG) { 259 + regs->psw.addr = regs->gprs[14]; 260 + btt = report_bug_entry((struct bug_entry *)regs->gprs[2], regs); 261 + } else { 262 + btt = report_bug(regs->psw.addr - (regs->int_code >> 16), regs); 263 + } 264 + switch (btt) { 229 265 case BUG_TRAP_TYPE_NONE: 230 266 fixup_exception(regs); 231 267 break; ··· 296 258 if (!IS_ENABLED(CONFIG_BUG)) 297 259 return; 298 260 asm_inline volatile( 299 - " mc 0,0\n" 261 + " mc %[monc](%%r0),0\n" 300 262 "0: lhi %[val],0\n" 301 263 "1:\n" 302 264 EX_TABLE(0b, 1b) 303 - : [val] "+d" (val)); 265 + : [val] "+d" (val) 266 + : [monc] "i" (MONCODE_BUG)); 304 267 if (!val) 305 268 panic("Monitor call doesn't work!\n"); 306 269 } ··· 336 297 teid.val = lc->trans_exc_code; 337 298 regs->int_code = lc->pgm_int_code; 338 299 regs->int_parm_long = teid.val; 300 + regs->monitor_code = lc->monitor_code; 339 301 /* 340 302 * In case of a guest fault, short-circuit the fault handler and return. 341 303 * This way the sie64a() function will return 0; fault address and
+25 -10
arch/s390/pci/pci.c
··· 231 231 static int zpci_cfg_load(struct zpci_dev *zdev, int offset, u32 *val, u8 len) 232 232 { 233 233 u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len); 234 + int rc = -ENODEV; 234 235 u64 data; 235 - int rc; 236 + 237 + if (!zdev_enabled(zdev)) 238 + goto out_err; 236 239 237 240 rc = __zpci_load(&data, req, offset); 238 - if (!rc) { 239 - data = le64_to_cpu((__force __le64) data); 240 - data >>= (8 - len) * 8; 241 - *val = (u32) data; 242 - } else 243 - *val = 0xffffffff; 241 + if (rc) 242 + goto out_err; 243 + data = le64_to_cpu((__force __le64)data); 244 + data >>= (8 - len) * 8; 245 + *val = (u32)data; 246 + return 0; 247 + 248 + out_err: 249 + PCI_SET_ERROR_RESPONSE(val); 244 250 return rc; 245 251 } 246 252 247 253 static int zpci_cfg_store(struct zpci_dev *zdev, int offset, u32 val, u8 len) 248 254 { 249 255 u64 req = ZPCI_CREATE_REQ(zdev->fh, ZPCI_PCIAS_CFGSPC, len); 256 + int rc = -ENODEV; 250 257 u64 data = val; 251 - int rc; 258 + 259 + if (!zdev_enabled(zdev)) 260 + return rc; 252 261 253 262 data <<= (8 - len) * 8; 254 263 data = (__force u64) cpu_to_le64(data); ··· 406 397 { 407 398 struct zpci_dev *zdev = zdev_from_bus(bus, devfn); 408 399 409 - return (zdev) ? zpci_cfg_load(zdev, where, val, size) : -ENODEV; 400 + if (!zdev || zpci_cfg_load(zdev, where, val, size)) 401 + return PCIBIOS_DEVICE_NOT_FOUND; 402 + return PCIBIOS_SUCCESSFUL; 410 403 } 411 404 412 405 static int pci_write(struct pci_bus *bus, unsigned int devfn, int where, ··· 416 405 { 417 406 struct zpci_dev *zdev = zdev_from_bus(bus, devfn); 418 407 419 - return (zdev) ? zpci_cfg_store(zdev, where, val, size) : -ENODEV; 408 + if (!zdev || zpci_cfg_store(zdev, where, val, size)) 409 + return PCIBIOS_DEVICE_NOT_FOUND; 410 + return PCIBIOS_SUCCESSFUL; 420 411 } 421 412 422 413 static struct pci_ops pci_root_ops = { ··· 1065 1052 { 1066 1053 BUILD_BUG_ON(!is_power_of_2(__alignof__(struct zpci_fmb)) || 1067 1054 __alignof__(struct zpci_fmb) < sizeof(struct zpci_fmb)); 1055 + BUILD_BUG_ON((CONFIG_ILLEGAL_POINTER_VALUE + 0x10000 > ZPCI_IOMAP_ADDR_BASE) && 1056 + (CONFIG_ILLEGAL_POINTER_VALUE <= ZPCI_IOMAP_ADDR_MAX)); 1068 1057 1069 1058 zdev_fmb_cache = kmem_cache_create("PCI_FMB_cache", sizeof(struct zpci_fmb), 1070 1059 __alignof__(struct zpci_fmb), 0, NULL);
+1
arch/s390/purgatory/Makefile
··· 23 23 KBUILD_CFLAGS += $(CLANG_FLAGS) 24 24 KBUILD_CFLAGS += $(if $(CONFIG_CC_IS_CLANG),-Wno-microsoft-anon-tag) 25 25 KBUILD_CFLAGS += $(call cc-option,-fno-PIE) 26 + KBUILD_CFLAGS += $(call cc-option, -Wno-default-const-init-unsafe) 26 27 KBUILD_AFLAGS := $(filter-out -DCC_USING_EXPOLINE,$(KBUILD_AFLAGS)) 27 28 KBUILD_AFLAGS += -D__DISABLE_EXPORTS 28 29
+4 -29
drivers/s390/char/Kconfig
··· 106 106 107 107 config S390_TAPE 108 108 def_tristate m 109 - prompt "S/390 tape device support" 109 + prompt "Support for 3490E tape on VTS" 110 110 depends on CCW 111 111 help 112 - Select this option if you want to access channel-attached tape 113 - devices on IBM S/390 or zSeries. 114 - If you select this option you will also want to select at 115 - least one of the tape interface options and one of the tape 116 - hardware options in order to access a tape device. 117 - This option is also available as a module. The module will be 118 - called tape390 and include all selected interfaces and 119 - hardware drivers. 120 - 121 - comment "S/390 tape hardware support" 122 - depends on S390_TAPE 123 - 124 - config S390_TAPE_34XX 125 - def_tristate m 126 - prompt "Support for 3480/3490 tape hardware" 127 - depends on S390_TAPE 128 - help 129 - Select this option if you want to access IBM 3480/3490 magnetic 130 - tape subsystems and 100% compatibles. 131 - It is safe to say "Y" here. 132 - 133 - config S390_TAPE_3590 134 - def_tristate m 135 - prompt "Support for 3590 tape hardware" 136 - depends on S390_TAPE 137 - help 138 - Select this option if you want to access IBM 3590 magnetic 139 - tape subsystems and 100% compatibles. 112 + Select this option if you want to access channel-attached IBM 3490E 113 + tape devices on VTS, such as IBM TS7700. 114 + This option is also available as a module. 140 115 It is safe to say "Y" here. 141 116 142 117 config VMLOGRDR
+2 -4
drivers/s390/char/Makefile
··· 39 39 obj-$(CONFIG_VMCP) += vmcp.o 40 40 41 41 tape-$(CONFIG_PROC_FS) += tape_proc.o 42 - tape-objs := tape_core.o tape_std.o tape_char.o $(tape-y) 43 - obj-$(CONFIG_S390_TAPE) += tape.o tape_class.o 44 - obj-$(CONFIG_S390_TAPE_34XX) += tape_34xx.o 45 - obj-$(CONFIG_S390_TAPE_3590) += tape_3590.o 42 + tape_s390-objs := tape_3490.o tape_char.o tape_class.o tape_core.o tape_std.o $(tape-y) 43 + obj-$(CONFIG_S390_TAPE) += tape_s390.o 46 44 obj-$(CONFIG_MONREADER) += monreader.o 47 45 obj-$(CONFIG_MONWRITER) += monwriter.o 48 46 obj-$(CONFIG_S390_VMUR) += vmur.o
+5 -8
drivers/s390/char/tape.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 2 /* 3 - * tape device driver for 3480/3490E/3590 tapes. 3 + * tape device driver for 3490E tapes. 4 4 * 5 5 * S390 and zSeries version 6 6 * Copyright IBM Corp. 2001, 2009 ··· 98 98 TO_DIS, /* Tape display */ 99 99 TO_ASSIGN, /* Assign tape to channel path */ 100 100 TO_UNASSIGN, /* Unassign tape from channel path */ 101 - TO_CRYPT_ON, /* Enable encrpytion */ 102 - TO_CRYPT_OFF, /* Disable encrpytion */ 103 - TO_KEKL_SET, /* Set KEK label */ 104 - TO_KEKL_QUERY, /* Query KEK label */ 105 101 TO_RDC, /* Read device characteristics */ 106 102 TO_SIZE, /* #entries in tape_op_t */ 107 103 }; ··· 151 155 struct tape_request *(*read_block)(struct tape_device *); 152 156 struct tape_request *(*write_block)(struct tape_device *); 153 157 void (*process_eov)(struct tape_device*); 154 - /* ioctl function for additional ioctls. */ 155 - int (*ioctl_fn)(struct tape_device *, unsigned int, unsigned long); 156 158 /* Array of tape commands with TAPE_NR_MTOPS entries */ 157 159 tape_mtop_fn *mtop_array; 158 160 }; ··· 186 192 187 193 /* Device discipline information. */ 188 194 struct tape_discipline * discipline; 189 - void * discdata; 190 195 191 196 /* Generic status flags */ 192 197 long tape_generic_status; ··· 273 280 extern void tapechar_exit(void); 274 281 extern int tapechar_setup_device(struct tape_device *); 275 282 extern void tapechar_cleanup_device(struct tape_device *); 283 + 284 + /* Externals from tape_3490.c */ 285 + extern int tape_3490_init(void); 286 + extern void tape_3490_exit(void); 276 287 277 288 /* tape initialisation functions */ 278 289 #ifdef CONFIG_PROC_FS
+825
drivers/s390/char/tape_3490.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * tape device discipline for 3490 tapes. 4 + * 5 + * Copyright IBM Corp. 2001, 2009 6 + * Author(s): Carsten Otte <cotte@de.ibm.com> 7 + * Tuan Ngo-Anh <ngoanh@de.ibm.com> 8 + * Martin Schwidefsky <schwidefsky@de.ibm.com> 9 + */ 10 + 11 + #define pr_fmt(fmt) "tape_3490: " fmt 12 + 13 + #include <linux/export.h> 14 + #include <linux/module.h> 15 + #include <linux/init.h> 16 + #include <linux/bio.h> 17 + #include <linux/workqueue.h> 18 + #include <linux/slab.h> 19 + 20 + #define TAPE_DBF_AREA tape_3490_dbf 21 + 22 + #include "tape.h" 23 + #include "tape_std.h" 24 + 25 + /* 26 + * Pointer to debug area. 27 + */ 28 + debug_info_t *TAPE_DBF_AREA = NULL; 29 + EXPORT_SYMBOL(TAPE_DBF_AREA); 30 + 31 + struct tape_3490_block_id { 32 + unsigned int unused : 10; 33 + unsigned int block : 22; 34 + }; 35 + 36 + /* 37 + * Medium sense for 3490 tapes. There is no 'real' medium sense call. 38 + * So we just do a normal sense. 39 + */ 40 + static void __tape_3490_medium_sense(struct tape_request *request) 41 + { 42 + struct tape_device *device = request->device; 43 + unsigned char *sense; 44 + 45 + if (request->rc == 0) { 46 + sense = request->cpdata; 47 + 48 + /* 49 + * This isn't quite correct. But since INTERVENTION_REQUIRED 50 + * means that the drive is 'neither ready nor on-line' it is 51 + * only slightly inaccurate to say there is no tape loaded if 52 + * the drive isn't online... 53 + */ 54 + if (sense[0] & SENSE_INTERVENTION_REQUIRED) 55 + tape_med_state_set(device, MS_UNLOADED); 56 + else 57 + tape_med_state_set(device, MS_LOADED); 58 + 59 + if (sense[1] & SENSE_WRITE_PROTECT) 60 + device->tape_generic_status |= GMT_WR_PROT(~0); 61 + else 62 + device->tape_generic_status &= ~GMT_WR_PROT(~0); 63 + } else 64 + DBF_EVENT(4, "tape_3490: medium sense failed with rc=%d\n", 65 + request->rc); 66 + tape_free_request(request); 67 + } 68 + 69 + static int tape_3490_medium_sense(struct tape_device *device) 70 + { 71 + struct tape_request *request; 72 + int rc; 73 + 74 + request = tape_alloc_request(1, 32); 75 + if (IS_ERR(request)) { 76 + DBF_EXCEPTION(6, "MSEN fail\n"); 77 + return PTR_ERR(request); 78 + } 79 + 80 + request->op = TO_MSEN; 81 + tape_ccw_end(request->cpaddr, SENSE, 32, request->cpdata); 82 + rc = tape_do_io_interruptible(device, request); 83 + __tape_3490_medium_sense(request); 84 + return rc; 85 + } 86 + 87 + static void tape_3490_medium_sense_async(struct tape_device *device) 88 + { 89 + struct tape_request *request; 90 + 91 + request = tape_alloc_request(1, 32); 92 + if (IS_ERR(request)) { 93 + DBF_EXCEPTION(6, "MSEN fail\n"); 94 + return; 95 + } 96 + 97 + request->op = TO_MSEN; 98 + tape_ccw_end(request->cpaddr, SENSE, 32, request->cpdata); 99 + request->callback = (void *) __tape_3490_medium_sense; 100 + request->callback_data = NULL; 101 + tape_do_io_async(device, request); 102 + } 103 + 104 + struct tape_3490_work { 105 + struct tape_device *device; 106 + enum tape_op op; 107 + struct work_struct work; 108 + }; 109 + 110 + /* 111 + * These functions are currently used only to schedule a medium_sense for 112 + * later execution. This is because we get an interrupt whenever a medium 113 + * is inserted but cannot call tape_do_io* from an interrupt context. 114 + * Maybe that's useful for other actions we want to start from the 115 + * interrupt handler. 116 + * Note: the work handler is called by the system work queue. The tape 117 + * commands started by the handler need to be asynchrounous, otherwise 118 + * a deadlock can occur e.g. in case of a deferred cc=1 (see __tape_do_irq). 119 + */ 120 + static void 121 + tape_3490_work_handler(struct work_struct *work) 122 + { 123 + struct tape_3490_work *p = 124 + container_of(work, struct tape_3490_work, work); 125 + struct tape_device *device = p->device; 126 + 127 + switch(p->op) { 128 + case TO_MSEN: 129 + tape_3490_medium_sense_async(device); 130 + break; 131 + default: 132 + DBF_EVENT(3, "T3490: internal error: unknown work\n"); 133 + } 134 + tape_put_device(device); 135 + kfree(p); 136 + } 137 + 138 + static int 139 + tape_3490_schedule_work(struct tape_device *device, enum tape_op op) 140 + { 141 + struct tape_3490_work *p; 142 + 143 + if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL) 144 + return -ENOMEM; 145 + 146 + INIT_WORK(&p->work, tape_3490_work_handler); 147 + 148 + p->device = tape_get_device(device); 149 + p->op = op; 150 + 151 + schedule_work(&p->work); 152 + return 0; 153 + } 154 + 155 + /* 156 + * Done Handler is called when dev stat = DEVICE-END (successful operation) 157 + */ 158 + static inline int 159 + tape_3490_done(struct tape_request *request) 160 + { 161 + DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]); 162 + return TAPE_IO_SUCCESS; 163 + } 164 + 165 + static inline int 166 + tape_3490_erp_failed(struct tape_request *request, int rc) 167 + { 168 + DBF_EVENT(3, "Error recovery failed for %s (RC=%d)\n", 169 + tape_op_verbose[request->op], rc); 170 + return rc; 171 + } 172 + 173 + static inline int 174 + tape_3490_erp_succeeded(struct tape_request *request) 175 + { 176 + DBF_EVENT(3, "Error Recovery successful for %s\n", 177 + tape_op_verbose[request->op]); 178 + return tape_3490_done(request); 179 + } 180 + 181 + static inline int 182 + tape_3490_erp_retry(struct tape_request *request) 183 + { 184 + DBF_EVENT(3, "xerp retr %s\n", tape_op_verbose[request->op]); 185 + return TAPE_IO_RETRY; 186 + } 187 + 188 + /* 189 + * This function is called, when no request is outstanding and we get an 190 + * interrupt 191 + */ 192 + static int 193 + tape_3490_unsolicited_irq(struct tape_device *device, struct irb *irb) 194 + { 195 + if (irb->scsw.cmd.dstat == 0x85) { /* READY */ 196 + /* A medium was inserted in the drive. */ 197 + DBF_EVENT(6, "xuud med\n"); 198 + tape_3490_schedule_work(device, TO_MSEN); 199 + } else { 200 + DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id); 201 + tape_dump_sense_dbf(device, NULL, irb); 202 + } 203 + return TAPE_IO_SUCCESS; 204 + } 205 + 206 + static int 207 + tape_3490_erp_bug(struct tape_device *device, struct tape_request *request, 208 + struct irb *irb, int no) 209 + { 210 + if (request->op != TO_ASSIGN) { 211 + dev_err(&device->cdev->dev, "An unexpected condition %d " 212 + "occurred in tape error recovery\n", no); 213 + tape_dump_sense_dbf(device, request, irb); 214 + } 215 + return tape_3490_erp_failed(request, -EIO); 216 + } 217 + 218 + /* 219 + * Handle data overrun between cu and drive. The channel speed might 220 + * be too slow. 221 + */ 222 + static int 223 + tape_3490_erp_overrun(struct tape_device *device, struct tape_request *request, 224 + struct irb *irb) 225 + { 226 + if (irb->ecw[3] == 0x40) { 227 + dev_warn (&device->cdev->dev, "A data overrun occurred between" 228 + " the control unit and tape unit\n"); 229 + return tape_3490_erp_failed(request, -EIO); 230 + } 231 + return tape_3490_erp_bug(device, request, irb, -1); 232 + } 233 + 234 + /* 235 + * Handle record sequence error. 236 + */ 237 + static int 238 + tape_3490_erp_sequence(struct tape_device *device, 239 + struct tape_request *request, struct irb *irb) 240 + { 241 + if (irb->ecw[3] == 0x41) { 242 + /* 243 + * cu detected incorrect block-id sequence on tape. 244 + */ 245 + dev_warn (&device->cdev->dev, "The block ID sequence on the " 246 + "tape is incorrect\n"); 247 + return tape_3490_erp_failed(request, -EIO); 248 + } 249 + /* 250 + * Record sequence error bit is set, but erpa does not 251 + * show record sequence error. 252 + */ 253 + return tape_3490_erp_bug(device, request, irb, -2); 254 + } 255 + 256 + /* 257 + * This function analyses the tape's sense-data in case of a unit-check. 258 + * If possible, it tries to recover from the error. Else the user is 259 + * informed about the problem. 260 + */ 261 + static int 262 + tape_3490_unit_check(struct tape_device *device, struct tape_request *request, 263 + struct irb *irb) 264 + { 265 + int inhibit_cu_recovery; 266 + __u8* sense; 267 + 268 + inhibit_cu_recovery = (*device->modeset_byte & 0x80) ? 1 : 0; 269 + sense = irb->ecw; 270 + 271 + if ( 272 + sense[0] & SENSE_COMMAND_REJECT && 273 + sense[1] & SENSE_WRITE_PROTECT 274 + ) { 275 + if ( 276 + request->op == TO_DSE || 277 + request->op == TO_WRI || 278 + request->op == TO_WTM 279 + ) { 280 + /* medium is write protected */ 281 + return tape_3490_erp_failed(request, -EACCES); 282 + } else { 283 + return tape_3490_erp_bug(device, request, irb, -3); 284 + } 285 + } 286 + 287 + /* 288 + * Special cases for various tape-states when reaching 289 + * end of recorded area 290 + * 291 + * FIXME: Maybe a special case of the special case: 292 + * sense[0] == SENSE_EQUIPMENT_CHECK && 293 + * sense[1] == SENSE_DRIVE_ONLINE && 294 + * sense[3] == 0x47 (Volume Fenced) 295 + * 296 + * This was caused by continued FSF or FSR after an 297 + * 'End Of Data'. 298 + */ 299 + if (( 300 + sense[0] == SENSE_DATA_CHECK || 301 + sense[0] == SENSE_EQUIPMENT_CHECK || 302 + sense[0] == (SENSE_EQUIPMENT_CHECK | SENSE_DEFERRED_UNIT_CHECK) 303 + ) && ( 304 + sense[1] == SENSE_DRIVE_ONLINE || 305 + sense[1] == (SENSE_BEGINNING_OF_TAPE | SENSE_WRITE_MODE) 306 + )) { 307 + switch (request->op) { 308 + /* 309 + * sense[0] == SENSE_DATA_CHECK && 310 + * sense[1] == SENSE_DRIVE_ONLINE 311 + * sense[3] == 0x36 (End Of Data) 312 + * 313 + * Further seeks might return a 'Volume Fenced'. 314 + */ 315 + case TO_FSF: 316 + case TO_FSB: 317 + /* Trying to seek beyond end of recorded area */ 318 + return tape_3490_erp_failed(request, -ENOSPC); 319 + case TO_BSB: 320 + return tape_3490_erp_retry(request); 321 + 322 + /* 323 + * sense[0] == SENSE_DATA_CHECK && 324 + * sense[1] == SENSE_DRIVE_ONLINE && 325 + * sense[3] == 0x36 (End Of Data) 326 + */ 327 + case TO_LBL: 328 + /* Block could not be located. */ 329 + return tape_3490_erp_failed(request, -EIO); 330 + 331 + case TO_RFO: 332 + /* Read beyond end of recorded area -> 0 bytes read */ 333 + return tape_3490_erp_failed(request, 0); 334 + 335 + /* 336 + * sense[0] == SENSE_EQUIPMENT_CHECK && 337 + * sense[1] == SENSE_DRIVE_ONLINE && 338 + * sense[3] == 0x38 (Physical End Of Volume) 339 + */ 340 + case TO_WRI: 341 + /* Writing at physical end of volume */ 342 + return tape_3490_erp_failed(request, -ENOSPC); 343 + default: 344 + return tape_3490_erp_failed(request, 0); 345 + } 346 + } 347 + 348 + /* Sensing special bits */ 349 + if (sense[0] & SENSE_BUS_OUT_CHECK) 350 + return tape_3490_erp_retry(request); 351 + 352 + if (sense[0] & SENSE_DATA_CHECK) { 353 + /* 354 + * hardware failure, damaged tape or improper 355 + * operating conditions 356 + */ 357 + switch (sense[3]) { 358 + case 0x23: 359 + /* a read data check occurred */ 360 + if ((sense[2] & SENSE_TAPE_SYNC_MODE) || 361 + inhibit_cu_recovery) 362 + // data check is not permanent, may be 363 + // recovered. We always use async-mode with 364 + // cu-recovery, so this should *never* happen. 365 + return tape_3490_erp_bug(device, request, 366 + irb, -4); 367 + 368 + /* data check is permanent, CU recovery has failed */ 369 + dev_warn (&device->cdev->dev, "A read error occurred " 370 + "that cannot be recovered\n"); 371 + return tape_3490_erp_failed(request, -EIO); 372 + case 0x25: 373 + // a write data check occurred 374 + if ((sense[2] & SENSE_TAPE_SYNC_MODE) || 375 + inhibit_cu_recovery) 376 + // data check is not permanent, may be 377 + // recovered. We always use async-mode with 378 + // cu-recovery, so this should *never* happen. 379 + return tape_3490_erp_bug(device, request, 380 + irb, -5); 381 + 382 + // data check is permanent, cu-recovery has failed 383 + dev_warn (&device->cdev->dev, "A write error on the " 384 + "tape cannot be recovered\n"); 385 + return tape_3490_erp_failed(request, -EIO); 386 + case 0x28: 387 + /* ID-Mark at tape start couldn't be written */ 388 + dev_warn (&device->cdev->dev, "Writing the ID-mark " 389 + "failed\n"); 390 + return tape_3490_erp_failed(request, -EIO); 391 + case 0x31: 392 + /* Tape void. Tried to read beyond end of device. */ 393 + dev_warn (&device->cdev->dev, "Reading the tape beyond" 394 + " the end of the recorded area failed\n"); 395 + return tape_3490_erp_failed(request, -ENOSPC); 396 + case 0x41: 397 + /* Record sequence error. */ 398 + dev_warn (&device->cdev->dev, "The tape contains an " 399 + "incorrect block ID sequence\n"); 400 + return tape_3490_erp_failed(request, -EIO); 401 + } 402 + } 403 + 404 + if (sense[0] & SENSE_OVERRUN) 405 + return tape_3490_erp_overrun(device, request, irb); 406 + 407 + if (sense[1] & SENSE_RECORD_SEQUENCE_ERR) 408 + return tape_3490_erp_sequence(device, request, irb); 409 + 410 + /* Sensing erpa codes */ 411 + switch (sense[3]) { 412 + case 0x00: 413 + /* Unit check with erpa code 0. Report and ignore. */ 414 + return TAPE_IO_SUCCESS; 415 + case 0x27: 416 + /* 417 + * Command reject. May indicate illegal channel program or 418 + * buffer over/underrun. Since all channel programs are 419 + * issued by this driver and ought be correct, we assume a 420 + * over/underrun situation and retry the channel program. 421 + */ 422 + return tape_3490_erp_retry(request); 423 + case 0x29: 424 + /* 425 + * Function incompatible. Either the tape is idrc compressed 426 + * but the hardware isn't capable to do idrc, or a perform 427 + * subsystem func is issued and the CU is not on-line. 428 + */ 429 + return tape_3490_erp_failed(request, -EIO); 430 + case 0x2b: 431 + /* 432 + * Environmental data present. Indicates either unload 433 + * completed ok or read buffered log command completed ok. 434 + */ 435 + if (request->op == TO_RUN) { 436 + /* Rewind unload completed ok. */ 437 + tape_med_state_set(device, MS_UNLOADED); 438 + return tape_3490_erp_succeeded(request); 439 + } 440 + /* tape_3490 doesn't use read buffered log commands. */ 441 + return tape_3490_erp_bug(device, request, irb, sense[3]); 442 + case 0x2c: 443 + /* 444 + * Permanent equipment check. CU has tried recovery, but 445 + * did not succeed. 446 + */ 447 + return tape_3490_erp_failed(request, -EIO); 448 + case 0x2d: 449 + /* Data security erase failure. */ 450 + if (request->op == TO_DSE) 451 + return tape_3490_erp_failed(request, -EIO); 452 + /* Data security erase failure, but no such command issued. */ 453 + return tape_3490_erp_bug(device, request, irb, sense[3]); 454 + case 0x2e: 455 + /* 456 + * Not capable. This indicates either that the drive fails 457 + * reading the format id mark or that format specified 458 + * is not supported by the drive. 459 + */ 460 + dev_warn (&device->cdev->dev, "The tape unit cannot process " 461 + "the tape format\n"); 462 + return tape_3490_erp_failed(request, -EMEDIUMTYPE); 463 + case 0x30: 464 + /* The medium is write protected. */ 465 + dev_warn (&device->cdev->dev, "The tape medium is write-" 466 + "protected\n"); 467 + return tape_3490_erp_failed(request, -EACCES); 468 + case 0x35: 469 + /* 470 + * Drive equipment check. One of the following: 471 + * - cu cannot recover from a drive detected error 472 + * - a check code message is shown on drive display 473 + * - the cartridge loader does not respond correctly 474 + * - a failure occurs during an index, load, or unload cycle 475 + */ 476 + dev_warn (&device->cdev->dev, "An equipment check has occurred" 477 + " on the tape unit\n"); 478 + return tape_3490_erp_failed(request, -EIO); 479 + case 0x36: 480 + /* End of data. */ 481 + return tape_3490_erp_failed(request, -EIO); 482 + case 0x38: 483 + /* 484 + * Physical end of tape. A read/write operation reached 485 + * the physical end of tape. 486 + */ 487 + if (request->op==TO_WRI || 488 + request->op==TO_DSE || 489 + request->op==TO_WTM) 490 + return tape_3490_erp_failed(request, -ENOSPC); 491 + return tape_3490_erp_failed(request, -EIO); 492 + case 0x39: 493 + /* Backward at Beginning of tape. */ 494 + return tape_3490_erp_failed(request, -EIO); 495 + case 0x42: 496 + /* 497 + * Degraded mode. A condition that can cause degraded 498 + * performance is detected. 499 + */ 500 + dev_warn (&device->cdev->dev, "The tape subsystem is running " 501 + "in degraded mode\n"); 502 + return tape_3490_erp_retry(request); 503 + case 0x43: 504 + /* Drive not ready. */ 505 + tape_med_state_set(device, MS_UNLOADED); 506 + /* Some commands commands are successful even in this case */ 507 + if (sense[1] & SENSE_DRIVE_ONLINE) { 508 + switch(request->op) { 509 + case TO_ASSIGN: 510 + case TO_UNASSIGN: 511 + case TO_DIS: 512 + case TO_NOP: 513 + return tape_3490_done(request); 514 + break; 515 + default: 516 + break; 517 + } 518 + } 519 + return tape_3490_erp_failed(request, -ENOMEDIUM); 520 + case 0x44: 521 + /* Locate Block unsuccessful. */ 522 + if (request->op != TO_BLOCK && request->op != TO_LBL) 523 + /* No locate block was issued. */ 524 + return tape_3490_erp_bug(device, request, 525 + irb, sense[3]); 526 + return tape_3490_erp_failed(request, -EIO); 527 + case 0x45: 528 + /* The drive is assigned to a different channel path. */ 529 + dev_warn (&device->cdev->dev, "The tape unit is already " 530 + "assigned\n"); 531 + return tape_3490_erp_failed(request, -EIO); 532 + case 0x47: 533 + /* Volume fenced. CU reports volume integrity is lost. */ 534 + dev_warn (&device->cdev->dev, "The control unit has fenced " 535 + "access to the tape volume\n"); 536 + return tape_3490_erp_failed(request, -EIO); 537 + case 0x48: 538 + /* Log sense data and retry request. */ 539 + return tape_3490_erp_retry(request); 540 + case 0x4d: 541 + /* 542 + * Resetting event received. Since the driver does 543 + * not support resetting event recovery (which has to 544 + * be handled by the I/O Layer), retry our command. 545 + */ 546 + return tape_3490_erp_retry(request); 547 + case 0x4e: 548 + /* 549 + * Maximum block size exceeded. This indicates, that 550 + * the block to be written is larger than allowed for 551 + * buffered mode. 552 + */ 553 + dev_warn (&device->cdev->dev, 554 + "The maximum block size for buffered mode is exceeded\n"); 555 + return tape_3490_erp_failed(request, -ENOBUFS); 556 + case 0x50: 557 + /* 558 + * Read buffered log (Overflow). CU is running in extended 559 + * buffered log mode, and a counter overflows. This should 560 + * never happen, since we're never running in extended 561 + * buffered log mode. 562 + */ 563 + return tape_3490_erp_retry(request); 564 + case 0x51: 565 + /* 566 + * Read buffered log (EOV). EOF processing occurs while the 567 + * CU is in extended buffered log mode. This should never 568 + * happen, since we're never running in extended buffered 569 + * log mode. 570 + */ 571 + return tape_3490_erp_retry(request); 572 + case 0x52: 573 + /* End of Volume complete. Rewind unload completed ok. */ 574 + if (request->op == TO_RUN) { 575 + tape_med_state_set(device, MS_UNLOADED); 576 + return tape_3490_erp_succeeded(request); 577 + } 578 + return tape_3490_erp_bug(device, request, irb, sense[3]); 579 + case 0x53: 580 + /* Global command intercept. */ 581 + return tape_3490_erp_retry(request); 582 + case 0x54: 583 + /* Channel interface recovery (temporary). */ 584 + return tape_3490_erp_retry(request); 585 + case 0x55: 586 + /* Channel interface recovery (permanent). */ 587 + dev_warn (&device->cdev->dev, "A channel interface error cannot be" 588 + " recovered\n"); 589 + return tape_3490_erp_failed(request, -EIO); 590 + case 0x56: 591 + /* Channel protocol error. */ 592 + dev_warn (&device->cdev->dev, "A channel protocol error " 593 + "occurred\n"); 594 + return tape_3490_erp_failed(request, -EIO); 595 + case 0x57: 596 + /* Global status intercept. */ 597 + return tape_3490_erp_retry(request); 598 + /* The following erpas should have been covered earlier. */ 599 + case 0x23: /* Read data check. */ 600 + case 0x25: /* Write data check. */ 601 + case 0x28: /* Write id mark check. */ 602 + case 0x31: /* Tape void. */ 603 + case 0x40: /* Overrun error. */ 604 + case 0x41: /* Record sequence error. */ 605 + /* All other erpas are reserved for future use. */ 606 + default: 607 + return tape_3490_erp_bug(device, request, irb, sense[3]); 608 + } 609 + } 610 + 611 + /* 612 + * 3490 interrupt handler 613 + */ 614 + static int 615 + tape_3490_irq(struct tape_device *device, struct tape_request *request, 616 + struct irb *irb) 617 + { 618 + if (request == NULL) 619 + return tape_3490_unsolicited_irq(device, irb); 620 + 621 + if ((irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) && 622 + (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) && 623 + (request->op == TO_WRI)) { 624 + /* Write at end of volume */ 625 + return tape_3490_erp_failed(request, -ENOSPC); 626 + } 627 + 628 + if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) 629 + return tape_3490_unit_check(device, request, irb); 630 + 631 + if (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) { 632 + /* 633 + * A unit exception occurs on skipping over a tapemark block. 634 + */ 635 + if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) { 636 + if (request->op == TO_BSB || request->op == TO_FSB) 637 + request->rescnt++; 638 + else 639 + DBF_EVENT(5, "Unit Exception!\n"); 640 + } 641 + return tape_3490_done(request); 642 + } 643 + 644 + DBF_EVENT(6, "xunknownirq\n"); 645 + tape_dump_sense_dbf(device, request, irb); 646 + return TAPE_IO_STOP; 647 + } 648 + 649 + static int 650 + tape_3490_setup_device(struct tape_device * device) 651 + { 652 + int rc; 653 + 654 + DBF_EVENT(6, "3490 device setup\n"); 655 + if ((rc = tape_std_assign(device)) == 0) { 656 + if ((rc = tape_3490_medium_sense(device)) != 0) { 657 + DBF_LH(3, "3490 medium sense returned %d\n", rc); 658 + } 659 + } 660 + return rc; 661 + } 662 + 663 + static void 664 + tape_3490_cleanup_device(struct tape_device *device) 665 + { 666 + tape_std_unassign(device); 667 + } 668 + 669 + 670 + /* 671 + * MTTELL: Tell block. Return the number of block relative to current file. 672 + */ 673 + static int 674 + tape_3490_mttell(struct tape_device *device, int mt_count) 675 + { 676 + struct { 677 + struct tape_3490_block_id cbid; 678 + struct tape_3490_block_id dbid; 679 + } __attribute__ ((packed)) block_id; 680 + int rc; 681 + 682 + rc = tape_std_read_block_id(device, (__u64 *) &block_id); 683 + if (rc) 684 + return rc; 685 + 686 + return block_id.cbid.block; 687 + } 688 + 689 + /* 690 + * MTSEEK: seek to the specified block. 691 + */ 692 + static int 693 + tape_3490_mtseek(struct tape_device *device, int mt_count) 694 + { 695 + struct tape_request *request; 696 + struct tape_3490_block_id * bid; 697 + 698 + if (mt_count > 0x3fffff) { 699 + DBF_EXCEPTION(6, "xsee parm\n"); 700 + return -EINVAL; 701 + } 702 + request = tape_alloc_request(3, 4); 703 + if (IS_ERR(request)) 704 + return PTR_ERR(request); 705 + 706 + /* setup ccws */ 707 + request->op = TO_LBL; 708 + bid = (struct tape_3490_block_id *) request->cpdata; 709 + bid->block = mt_count; 710 + 711 + tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); 712 + tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata); 713 + tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL); 714 + 715 + /* execute it */ 716 + return tape_do_io_free(device, request); 717 + } 718 + 719 + /* 720 + * List of 3490 tape commands. 721 + */ 722 + static tape_mtop_fn tape_3490_mtop[TAPE_NR_MTOPS] = { 723 + [MTRESET] = tape_std_mtreset, 724 + [MTFSF] = tape_std_mtfsf, 725 + [MTBSF] = tape_std_mtbsf, 726 + [MTFSR] = tape_std_mtfsr, 727 + [MTBSR] = tape_std_mtbsr, 728 + [MTWEOF] = tape_std_mtweof, 729 + [MTREW] = tape_std_mtrew, 730 + [MTOFFL] = tape_std_mtoffl, 731 + [MTNOP] = tape_std_mtnop, 732 + [MTRETEN] = tape_std_mtreten, 733 + [MTBSFM] = tape_std_mtbsfm, 734 + [MTFSFM] = tape_std_mtfsfm, 735 + [MTEOM] = tape_std_mteom, 736 + [MTERASE] = tape_std_mterase, 737 + [MTRAS1] = NULL, 738 + [MTRAS2] = NULL, 739 + [MTRAS3] = NULL, 740 + [MTSETBLK] = tape_std_mtsetblk, 741 + [MTSETDENSITY] = NULL, 742 + [MTSEEK] = tape_3490_mtseek, 743 + [MTTELL] = tape_3490_mttell, 744 + [MTSETDRVBUFFER] = NULL, 745 + [MTFSS] = NULL, 746 + [MTBSS] = NULL, 747 + [MTWSM] = NULL, 748 + [MTLOCK] = NULL, 749 + [MTUNLOCK] = NULL, 750 + [MTLOAD] = tape_std_mtload, 751 + [MTUNLOAD] = tape_std_mtunload, 752 + [MTCOMPRESSION] = tape_std_mtcompression, 753 + [MTSETPART] = NULL, 754 + [MTMKPART] = NULL 755 + }; 756 + 757 + /* 758 + * Tape discipline structure for 3490. 759 + */ 760 + static struct tape_discipline tape_discipline_3490 = { 761 + .owner = THIS_MODULE, 762 + .setup_device = tape_3490_setup_device, 763 + .cleanup_device = tape_3490_cleanup_device, 764 + .process_eov = tape_std_process_eov, 765 + .irq = tape_3490_irq, 766 + .read_block = tape_std_read_block, 767 + .write_block = tape_std_write_block, 768 + .mtop_array = tape_3490_mtop 769 + }; 770 + 771 + static struct ccw_device_id tape_3490_ids[] = { 772 + { CCW_DEVICE_DEVTYPE(0x3490, 0, 0x3490, 0), .driver_info = tape_3490}, 773 + { /* end of list */ }, 774 + }; 775 + 776 + static int 777 + tape_3490_online(struct ccw_device *cdev) 778 + { 779 + return tape_generic_online( 780 + dev_get_drvdata(&cdev->dev), 781 + &tape_discipline_3490 782 + ); 783 + } 784 + 785 + static struct ccw_driver tape_3490_driver = { 786 + .driver = { 787 + .name = "tape_3490", 788 + .owner = THIS_MODULE, 789 + }, 790 + .ids = tape_3490_ids, 791 + .probe = tape_generic_probe, 792 + .remove = tape_generic_remove, 793 + .set_online = tape_3490_online, 794 + .set_offline = tape_generic_offline, 795 + .int_class = IRQIO_TAP, 796 + }; 797 + 798 + int tape_3490_init(void) 799 + { 800 + int rc; 801 + 802 + TAPE_DBF_AREA = debug_register ( "tape_3490", 2, 2, 4*sizeof(long)); 803 + debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view); 804 + #ifdef DBF_LIKE_HELL 805 + debug_set_level(TAPE_DBF_AREA, 6); 806 + #endif 807 + 808 + DBF_EVENT(3, "3490 init\n"); 809 + /* Register driver for 3490 tapes. */ 810 + rc = ccw_driver_register(&tape_3490_driver); 811 + if (rc) 812 + DBF_EVENT(3, "3490 init failed\n"); 813 + else 814 + DBF_EVENT(3, "3490 registered\n"); 815 + return rc; 816 + } 817 + 818 + void tape_3490_exit(void) 819 + { 820 + ccw_driver_unregister(&tape_3490_driver); 821 + 822 + debug_unregister(TAPE_DBF_AREA); 823 + } 824 + 825 + MODULE_DEVICE_TABLE(ccw, tape_3490_ids);
-1204
drivers/s390/char/tape_34xx.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * tape device discipline for 3480/3490 tapes. 4 - * 5 - * Copyright IBM Corp. 2001, 2009 6 - * Author(s): Carsten Otte <cotte@de.ibm.com> 7 - * Tuan Ngo-Anh <ngoanh@de.ibm.com> 8 - * Martin Schwidefsky <schwidefsky@de.ibm.com> 9 - */ 10 - 11 - #define pr_fmt(fmt) "tape_34xx: " fmt 12 - 13 - #include <linux/export.h> 14 - #include <linux/module.h> 15 - #include <linux/init.h> 16 - #include <linux/bio.h> 17 - #include <linux/workqueue.h> 18 - #include <linux/slab.h> 19 - 20 - #define TAPE_DBF_AREA tape_34xx_dbf 21 - 22 - #include "tape.h" 23 - #include "tape_std.h" 24 - 25 - /* 26 - * Pointer to debug area. 27 - */ 28 - debug_info_t *TAPE_DBF_AREA = NULL; 29 - EXPORT_SYMBOL(TAPE_DBF_AREA); 30 - 31 - #define TAPE34XX_FMT_3480 0 32 - #define TAPE34XX_FMT_3480_2_XF 1 33 - #define TAPE34XX_FMT_3480_XF 2 34 - 35 - struct tape_34xx_block_id { 36 - unsigned int wrap : 1; 37 - unsigned int segment : 7; 38 - unsigned int format : 2; 39 - unsigned int block : 22; 40 - }; 41 - 42 - /* 43 - * A list of block ID's is used to faster seek blocks. 44 - */ 45 - struct tape_34xx_sbid { 46 - struct list_head list; 47 - struct tape_34xx_block_id bid; 48 - }; 49 - 50 - static void tape_34xx_delete_sbid_from(struct tape_device *, int); 51 - 52 - /* 53 - * Medium sense for 34xx tapes. There is no 'real' medium sense call. 54 - * So we just do a normal sense. 55 - */ 56 - static void __tape_34xx_medium_sense(struct tape_request *request) 57 - { 58 - struct tape_device *device = request->device; 59 - unsigned char *sense; 60 - 61 - if (request->rc == 0) { 62 - sense = request->cpdata; 63 - 64 - /* 65 - * This isn't quite correct. But since INTERVENTION_REQUIRED 66 - * means that the drive is 'neither ready nor on-line' it is 67 - * only slightly inaccurate to say there is no tape loaded if 68 - * the drive isn't online... 69 - */ 70 - if (sense[0] & SENSE_INTERVENTION_REQUIRED) 71 - tape_med_state_set(device, MS_UNLOADED); 72 - else 73 - tape_med_state_set(device, MS_LOADED); 74 - 75 - if (sense[1] & SENSE_WRITE_PROTECT) 76 - device->tape_generic_status |= GMT_WR_PROT(~0); 77 - else 78 - device->tape_generic_status &= ~GMT_WR_PROT(~0); 79 - } else 80 - DBF_EVENT(4, "tape_34xx: medium sense failed with rc=%d\n", 81 - request->rc); 82 - tape_free_request(request); 83 - } 84 - 85 - static int tape_34xx_medium_sense(struct tape_device *device) 86 - { 87 - struct tape_request *request; 88 - int rc; 89 - 90 - request = tape_alloc_request(1, 32); 91 - if (IS_ERR(request)) { 92 - DBF_EXCEPTION(6, "MSEN fail\n"); 93 - return PTR_ERR(request); 94 - } 95 - 96 - request->op = TO_MSEN; 97 - tape_ccw_end(request->cpaddr, SENSE, 32, request->cpdata); 98 - rc = tape_do_io_interruptible(device, request); 99 - __tape_34xx_medium_sense(request); 100 - return rc; 101 - } 102 - 103 - static void tape_34xx_medium_sense_async(struct tape_device *device) 104 - { 105 - struct tape_request *request; 106 - 107 - request = tape_alloc_request(1, 32); 108 - if (IS_ERR(request)) { 109 - DBF_EXCEPTION(6, "MSEN fail\n"); 110 - return; 111 - } 112 - 113 - request->op = TO_MSEN; 114 - tape_ccw_end(request->cpaddr, SENSE, 32, request->cpdata); 115 - request->callback = (void *) __tape_34xx_medium_sense; 116 - request->callback_data = NULL; 117 - tape_do_io_async(device, request); 118 - } 119 - 120 - struct tape_34xx_work { 121 - struct tape_device *device; 122 - enum tape_op op; 123 - struct work_struct work; 124 - }; 125 - 126 - /* 127 - * These functions are currently used only to schedule a medium_sense for 128 - * later execution. This is because we get an interrupt whenever a medium 129 - * is inserted but cannot call tape_do_io* from an interrupt context. 130 - * Maybe that's useful for other actions we want to start from the 131 - * interrupt handler. 132 - * Note: the work handler is called by the system work queue. The tape 133 - * commands started by the handler need to be asynchrounous, otherwise 134 - * a deadlock can occur e.g. in case of a deferred cc=1 (see __tape_do_irq). 135 - */ 136 - static void 137 - tape_34xx_work_handler(struct work_struct *work) 138 - { 139 - struct tape_34xx_work *p = 140 - container_of(work, struct tape_34xx_work, work); 141 - struct tape_device *device = p->device; 142 - 143 - switch(p->op) { 144 - case TO_MSEN: 145 - tape_34xx_medium_sense_async(device); 146 - break; 147 - default: 148 - DBF_EVENT(3, "T34XX: internal error: unknown work\n"); 149 - } 150 - tape_put_device(device); 151 - kfree(p); 152 - } 153 - 154 - static int 155 - tape_34xx_schedule_work(struct tape_device *device, enum tape_op op) 156 - { 157 - struct tape_34xx_work *p; 158 - 159 - if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL) 160 - return -ENOMEM; 161 - 162 - INIT_WORK(&p->work, tape_34xx_work_handler); 163 - 164 - p->device = tape_get_device(device); 165 - p->op = op; 166 - 167 - schedule_work(&p->work); 168 - return 0; 169 - } 170 - 171 - /* 172 - * Done Handler is called when dev stat = DEVICE-END (successful operation) 173 - */ 174 - static inline int 175 - tape_34xx_done(struct tape_request *request) 176 - { 177 - DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]); 178 - 179 - switch (request->op) { 180 - case TO_DSE: 181 - case TO_RUN: 182 - case TO_WRI: 183 - case TO_WTM: 184 - case TO_ASSIGN: 185 - case TO_UNASSIGN: 186 - tape_34xx_delete_sbid_from(request->device, 0); 187 - break; 188 - default: 189 - ; 190 - } 191 - return TAPE_IO_SUCCESS; 192 - } 193 - 194 - static inline int 195 - tape_34xx_erp_failed(struct tape_request *request, int rc) 196 - { 197 - DBF_EVENT(3, "Error recovery failed for %s (RC=%d)\n", 198 - tape_op_verbose[request->op], rc); 199 - return rc; 200 - } 201 - 202 - static inline int 203 - tape_34xx_erp_succeeded(struct tape_request *request) 204 - { 205 - DBF_EVENT(3, "Error Recovery successful for %s\n", 206 - tape_op_verbose[request->op]); 207 - return tape_34xx_done(request); 208 - } 209 - 210 - static inline int 211 - tape_34xx_erp_retry(struct tape_request *request) 212 - { 213 - DBF_EVENT(3, "xerp retr %s\n", tape_op_verbose[request->op]); 214 - return TAPE_IO_RETRY; 215 - } 216 - 217 - /* 218 - * This function is called, when no request is outstanding and we get an 219 - * interrupt 220 - */ 221 - static int 222 - tape_34xx_unsolicited_irq(struct tape_device *device, struct irb *irb) 223 - { 224 - if (irb->scsw.cmd.dstat == 0x85) { /* READY */ 225 - /* A medium was inserted in the drive. */ 226 - DBF_EVENT(6, "xuud med\n"); 227 - tape_34xx_delete_sbid_from(device, 0); 228 - tape_34xx_schedule_work(device, TO_MSEN); 229 - } else { 230 - DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id); 231 - tape_dump_sense_dbf(device, NULL, irb); 232 - } 233 - return TAPE_IO_SUCCESS; 234 - } 235 - 236 - static int 237 - tape_34xx_erp_bug(struct tape_device *device, struct tape_request *request, 238 - struct irb *irb, int no) 239 - { 240 - if (request->op != TO_ASSIGN) { 241 - dev_err(&device->cdev->dev, "An unexpected condition %d " 242 - "occurred in tape error recovery\n", no); 243 - tape_dump_sense_dbf(device, request, irb); 244 - } 245 - return tape_34xx_erp_failed(request, -EIO); 246 - } 247 - 248 - /* 249 - * Handle data overrun between cu and drive. The channel speed might 250 - * be too slow. 251 - */ 252 - static int 253 - tape_34xx_erp_overrun(struct tape_device *device, struct tape_request *request, 254 - struct irb *irb) 255 - { 256 - if (irb->ecw[3] == 0x40) { 257 - dev_warn (&device->cdev->dev, "A data overrun occurred between" 258 - " the control unit and tape unit\n"); 259 - return tape_34xx_erp_failed(request, -EIO); 260 - } 261 - return tape_34xx_erp_bug(device, request, irb, -1); 262 - } 263 - 264 - /* 265 - * Handle record sequence error. 266 - */ 267 - static int 268 - tape_34xx_erp_sequence(struct tape_device *device, 269 - struct tape_request *request, struct irb *irb) 270 - { 271 - if (irb->ecw[3] == 0x41) { 272 - /* 273 - * cu detected incorrect block-id sequence on tape. 274 - */ 275 - dev_warn (&device->cdev->dev, "The block ID sequence on the " 276 - "tape is incorrect\n"); 277 - return tape_34xx_erp_failed(request, -EIO); 278 - } 279 - /* 280 - * Record sequence error bit is set, but erpa does not 281 - * show record sequence error. 282 - */ 283 - return tape_34xx_erp_bug(device, request, irb, -2); 284 - } 285 - 286 - /* 287 - * This function analyses the tape's sense-data in case of a unit-check. 288 - * If possible, it tries to recover from the error. Else the user is 289 - * informed about the problem. 290 - */ 291 - static int 292 - tape_34xx_unit_check(struct tape_device *device, struct tape_request *request, 293 - struct irb *irb) 294 - { 295 - int inhibit_cu_recovery; 296 - __u8* sense; 297 - 298 - inhibit_cu_recovery = (*device->modeset_byte & 0x80) ? 1 : 0; 299 - sense = irb->ecw; 300 - 301 - if ( 302 - sense[0] & SENSE_COMMAND_REJECT && 303 - sense[1] & SENSE_WRITE_PROTECT 304 - ) { 305 - if ( 306 - request->op == TO_DSE || 307 - request->op == TO_WRI || 308 - request->op == TO_WTM 309 - ) { 310 - /* medium is write protected */ 311 - return tape_34xx_erp_failed(request, -EACCES); 312 - } else { 313 - return tape_34xx_erp_bug(device, request, irb, -3); 314 - } 315 - } 316 - 317 - /* 318 - * Special cases for various tape-states when reaching 319 - * end of recorded area 320 - * 321 - * FIXME: Maybe a special case of the special case: 322 - * sense[0] == SENSE_EQUIPMENT_CHECK && 323 - * sense[1] == SENSE_DRIVE_ONLINE && 324 - * sense[3] == 0x47 (Volume Fenced) 325 - * 326 - * This was caused by continued FSF or FSR after an 327 - * 'End Of Data'. 328 - */ 329 - if (( 330 - sense[0] == SENSE_DATA_CHECK || 331 - sense[0] == SENSE_EQUIPMENT_CHECK || 332 - sense[0] == (SENSE_EQUIPMENT_CHECK | SENSE_DEFERRED_UNIT_CHECK) 333 - ) && ( 334 - sense[1] == SENSE_DRIVE_ONLINE || 335 - sense[1] == (SENSE_BEGINNING_OF_TAPE | SENSE_WRITE_MODE) 336 - )) { 337 - switch (request->op) { 338 - /* 339 - * sense[0] == SENSE_DATA_CHECK && 340 - * sense[1] == SENSE_DRIVE_ONLINE 341 - * sense[3] == 0x36 (End Of Data) 342 - * 343 - * Further seeks might return a 'Volume Fenced'. 344 - */ 345 - case TO_FSF: 346 - case TO_FSB: 347 - /* Trying to seek beyond end of recorded area */ 348 - return tape_34xx_erp_failed(request, -ENOSPC); 349 - case TO_BSB: 350 - return tape_34xx_erp_retry(request); 351 - 352 - /* 353 - * sense[0] == SENSE_DATA_CHECK && 354 - * sense[1] == SENSE_DRIVE_ONLINE && 355 - * sense[3] == 0x36 (End Of Data) 356 - */ 357 - case TO_LBL: 358 - /* Block could not be located. */ 359 - tape_34xx_delete_sbid_from(device, 0); 360 - return tape_34xx_erp_failed(request, -EIO); 361 - 362 - case TO_RFO: 363 - /* Read beyond end of recorded area -> 0 bytes read */ 364 - return tape_34xx_erp_failed(request, 0); 365 - 366 - /* 367 - * sense[0] == SENSE_EQUIPMENT_CHECK && 368 - * sense[1] == SENSE_DRIVE_ONLINE && 369 - * sense[3] == 0x38 (Physical End Of Volume) 370 - */ 371 - case TO_WRI: 372 - /* Writing at physical end of volume */ 373 - return tape_34xx_erp_failed(request, -ENOSPC); 374 - default: 375 - return tape_34xx_erp_failed(request, 0); 376 - } 377 - } 378 - 379 - /* Sensing special bits */ 380 - if (sense[0] & SENSE_BUS_OUT_CHECK) 381 - return tape_34xx_erp_retry(request); 382 - 383 - if (sense[0] & SENSE_DATA_CHECK) { 384 - /* 385 - * hardware failure, damaged tape or improper 386 - * operating conditions 387 - */ 388 - switch (sense[3]) { 389 - case 0x23: 390 - /* a read data check occurred */ 391 - if ((sense[2] & SENSE_TAPE_SYNC_MODE) || 392 - inhibit_cu_recovery) 393 - // data check is not permanent, may be 394 - // recovered. We always use async-mode with 395 - // cu-recovery, so this should *never* happen. 396 - return tape_34xx_erp_bug(device, request, 397 - irb, -4); 398 - 399 - /* data check is permanent, CU recovery has failed */ 400 - dev_warn (&device->cdev->dev, "A read error occurred " 401 - "that cannot be recovered\n"); 402 - return tape_34xx_erp_failed(request, -EIO); 403 - case 0x25: 404 - // a write data check occurred 405 - if ((sense[2] & SENSE_TAPE_SYNC_MODE) || 406 - inhibit_cu_recovery) 407 - // data check is not permanent, may be 408 - // recovered. We always use async-mode with 409 - // cu-recovery, so this should *never* happen. 410 - return tape_34xx_erp_bug(device, request, 411 - irb, -5); 412 - 413 - // data check is permanent, cu-recovery has failed 414 - dev_warn (&device->cdev->dev, "A write error on the " 415 - "tape cannot be recovered\n"); 416 - return tape_34xx_erp_failed(request, -EIO); 417 - case 0x28: 418 - /* ID-Mark at tape start couldn't be written */ 419 - dev_warn (&device->cdev->dev, "Writing the ID-mark " 420 - "failed\n"); 421 - return tape_34xx_erp_failed(request, -EIO); 422 - case 0x31: 423 - /* Tape void. Tried to read beyond end of device. */ 424 - dev_warn (&device->cdev->dev, "Reading the tape beyond" 425 - " the end of the recorded area failed\n"); 426 - return tape_34xx_erp_failed(request, -ENOSPC); 427 - case 0x41: 428 - /* Record sequence error. */ 429 - dev_warn (&device->cdev->dev, "The tape contains an " 430 - "incorrect block ID sequence\n"); 431 - return tape_34xx_erp_failed(request, -EIO); 432 - default: 433 - /* all data checks for 3480 should result in one of 434 - * the above erpa-codes. For 3490, other data-check 435 - * conditions do exist. */ 436 - if (device->cdev->id.driver_info == tape_3480) 437 - return tape_34xx_erp_bug(device, request, 438 - irb, -6); 439 - } 440 - } 441 - 442 - if (sense[0] & SENSE_OVERRUN) 443 - return tape_34xx_erp_overrun(device, request, irb); 444 - 445 - if (sense[1] & SENSE_RECORD_SEQUENCE_ERR) 446 - return tape_34xx_erp_sequence(device, request, irb); 447 - 448 - /* Sensing erpa codes */ 449 - switch (sense[3]) { 450 - case 0x00: 451 - /* Unit check with erpa code 0. Report and ignore. */ 452 - return TAPE_IO_SUCCESS; 453 - case 0x21: 454 - /* 455 - * Data streaming not operational. CU will switch to 456 - * interlock mode. Reissue the command. 457 - */ 458 - return tape_34xx_erp_retry(request); 459 - case 0x22: 460 - /* 461 - * Path equipment check. Might be drive adapter error, buffer 462 - * error on the lower interface, internal path not usable, 463 - * or error during cartridge load. 464 - */ 465 - dev_warn (&device->cdev->dev, "A path equipment check occurred" 466 - " for the tape device\n"); 467 - return tape_34xx_erp_failed(request, -EIO); 468 - case 0x24: 469 - /* 470 - * Load display check. Load display was command was issued, 471 - * but the drive is displaying a drive check message. Can 472 - * be threated as "device end". 473 - */ 474 - return tape_34xx_erp_succeeded(request); 475 - case 0x27: 476 - /* 477 - * Command reject. May indicate illegal channel program or 478 - * buffer over/underrun. Since all channel programs are 479 - * issued by this driver and ought be correct, we assume a 480 - * over/underrun situation and retry the channel program. 481 - */ 482 - return tape_34xx_erp_retry(request); 483 - case 0x29: 484 - /* 485 - * Function incompatible. Either the tape is idrc compressed 486 - * but the hardware isn't capable to do idrc, or a perform 487 - * subsystem func is issued and the CU is not on-line. 488 - */ 489 - return tape_34xx_erp_failed(request, -EIO); 490 - case 0x2a: 491 - /* 492 - * Unsolicited environmental data. An internal counter 493 - * overflows, we can ignore this and reissue the cmd. 494 - */ 495 - return tape_34xx_erp_retry(request); 496 - case 0x2b: 497 - /* 498 - * Environmental data present. Indicates either unload 499 - * completed ok or read buffered log command completed ok. 500 - */ 501 - if (request->op == TO_RUN) { 502 - /* Rewind unload completed ok. */ 503 - tape_med_state_set(device, MS_UNLOADED); 504 - return tape_34xx_erp_succeeded(request); 505 - } 506 - /* tape_34xx doesn't use read buffered log commands. */ 507 - return tape_34xx_erp_bug(device, request, irb, sense[3]); 508 - case 0x2c: 509 - /* 510 - * Permanent equipment check. CU has tried recovery, but 511 - * did not succeed. 512 - */ 513 - return tape_34xx_erp_failed(request, -EIO); 514 - case 0x2d: 515 - /* Data security erase failure. */ 516 - if (request->op == TO_DSE) 517 - return tape_34xx_erp_failed(request, -EIO); 518 - /* Data security erase failure, but no such command issued. */ 519 - return tape_34xx_erp_bug(device, request, irb, sense[3]); 520 - case 0x2e: 521 - /* 522 - * Not capable. This indicates either that the drive fails 523 - * reading the format id mark or that format specified 524 - * is not supported by the drive. 525 - */ 526 - dev_warn (&device->cdev->dev, "The tape unit cannot process " 527 - "the tape format\n"); 528 - return tape_34xx_erp_failed(request, -EMEDIUMTYPE); 529 - case 0x30: 530 - /* The medium is write protected. */ 531 - dev_warn (&device->cdev->dev, "The tape medium is write-" 532 - "protected\n"); 533 - return tape_34xx_erp_failed(request, -EACCES); 534 - case 0x32: 535 - // Tension loss. We cannot recover this, it's an I/O error. 536 - dev_warn (&device->cdev->dev, "The tape does not have the " 537 - "required tape tension\n"); 538 - return tape_34xx_erp_failed(request, -EIO); 539 - case 0x33: 540 - /* 541 - * Load Failure. The cartridge was not inserted correctly or 542 - * the tape is not threaded correctly. 543 - */ 544 - dev_warn (&device->cdev->dev, "The tape unit failed to load" 545 - " the cartridge\n"); 546 - tape_34xx_delete_sbid_from(device, 0); 547 - return tape_34xx_erp_failed(request, -EIO); 548 - case 0x34: 549 - /* 550 - * Unload failure. The drive cannot maintain tape tension 551 - * and control tape movement during an unload operation. 552 - */ 553 - dev_warn (&device->cdev->dev, "Automatic unloading of the tape" 554 - " cartridge failed\n"); 555 - if (request->op == TO_RUN) 556 - return tape_34xx_erp_failed(request, -EIO); 557 - return tape_34xx_erp_bug(device, request, irb, sense[3]); 558 - case 0x35: 559 - /* 560 - * Drive equipment check. One of the following: 561 - * - cu cannot recover from a drive detected error 562 - * - a check code message is shown on drive display 563 - * - the cartridge loader does not respond correctly 564 - * - a failure occurs during an index, load, or unload cycle 565 - */ 566 - dev_warn (&device->cdev->dev, "An equipment check has occurred" 567 - " on the tape unit\n"); 568 - return tape_34xx_erp_failed(request, -EIO); 569 - case 0x36: 570 - if (device->cdev->id.driver_info == tape_3490) 571 - /* End of data. */ 572 - return tape_34xx_erp_failed(request, -EIO); 573 - /* This erpa is reserved for 3480 */ 574 - return tape_34xx_erp_bug(device, request, irb, sense[3]); 575 - case 0x37: 576 - /* 577 - * Tape length error. The tape is shorter than reported in 578 - * the beginning-of-tape data. 579 - */ 580 - dev_warn (&device->cdev->dev, "The tape information states an" 581 - " incorrect length\n"); 582 - return tape_34xx_erp_failed(request, -EIO); 583 - case 0x38: 584 - /* 585 - * Physical end of tape. A read/write operation reached 586 - * the physical end of tape. 587 - */ 588 - if (request->op==TO_WRI || 589 - request->op==TO_DSE || 590 - request->op==TO_WTM) 591 - return tape_34xx_erp_failed(request, -ENOSPC); 592 - return tape_34xx_erp_failed(request, -EIO); 593 - case 0x39: 594 - /* Backward at Beginning of tape. */ 595 - return tape_34xx_erp_failed(request, -EIO); 596 - case 0x3a: 597 - /* Drive switched to not ready. */ 598 - dev_warn (&device->cdev->dev, "The tape unit is not ready\n"); 599 - return tape_34xx_erp_failed(request, -EIO); 600 - case 0x3b: 601 - /* Manual rewind or unload. This causes an I/O error. */ 602 - dev_warn (&device->cdev->dev, "The tape medium has been " 603 - "rewound or unloaded manually\n"); 604 - tape_34xx_delete_sbid_from(device, 0); 605 - return tape_34xx_erp_failed(request, -EIO); 606 - case 0x42: 607 - /* 608 - * Degraded mode. A condition that can cause degraded 609 - * performance is detected. 610 - */ 611 - dev_warn (&device->cdev->dev, "The tape subsystem is running " 612 - "in degraded mode\n"); 613 - return tape_34xx_erp_retry(request); 614 - case 0x43: 615 - /* Drive not ready. */ 616 - tape_34xx_delete_sbid_from(device, 0); 617 - tape_med_state_set(device, MS_UNLOADED); 618 - /* Some commands commands are successful even in this case */ 619 - if (sense[1] & SENSE_DRIVE_ONLINE) { 620 - switch(request->op) { 621 - case TO_ASSIGN: 622 - case TO_UNASSIGN: 623 - case TO_DIS: 624 - case TO_NOP: 625 - return tape_34xx_done(request); 626 - break; 627 - default: 628 - break; 629 - } 630 - } 631 - return tape_34xx_erp_failed(request, -ENOMEDIUM); 632 - case 0x44: 633 - /* Locate Block unsuccessful. */ 634 - if (request->op != TO_BLOCK && request->op != TO_LBL) 635 - /* No locate block was issued. */ 636 - return tape_34xx_erp_bug(device, request, 637 - irb, sense[3]); 638 - return tape_34xx_erp_failed(request, -EIO); 639 - case 0x45: 640 - /* The drive is assigned to a different channel path. */ 641 - dev_warn (&device->cdev->dev, "The tape unit is already " 642 - "assigned\n"); 643 - return tape_34xx_erp_failed(request, -EIO); 644 - case 0x46: 645 - /* 646 - * Drive not on-line. Drive may be switched offline, 647 - * the power supply may be switched off or 648 - * the drive address may not be set correctly. 649 - */ 650 - dev_warn (&device->cdev->dev, "The tape unit is not online\n"); 651 - return tape_34xx_erp_failed(request, -EIO); 652 - case 0x47: 653 - /* Volume fenced. CU reports volume integrity is lost. */ 654 - dev_warn (&device->cdev->dev, "The control unit has fenced " 655 - "access to the tape volume\n"); 656 - tape_34xx_delete_sbid_from(device, 0); 657 - return tape_34xx_erp_failed(request, -EIO); 658 - case 0x48: 659 - /* Log sense data and retry request. */ 660 - return tape_34xx_erp_retry(request); 661 - case 0x49: 662 - /* Bus out check. A parity check error on the bus was found. */ 663 - dev_warn (&device->cdev->dev, "A parity error occurred on the " 664 - "tape bus\n"); 665 - return tape_34xx_erp_failed(request, -EIO); 666 - case 0x4a: 667 - /* Control unit erp failed. */ 668 - dev_warn (&device->cdev->dev, "I/O error recovery failed on " 669 - "the tape control unit\n"); 670 - return tape_34xx_erp_failed(request, -EIO); 671 - case 0x4b: 672 - /* 673 - * CU and drive incompatible. The drive requests micro-program 674 - * patches, which are not available on the CU. 675 - */ 676 - dev_warn (&device->cdev->dev, "The tape unit requires a " 677 - "firmware update\n"); 678 - return tape_34xx_erp_failed(request, -EIO); 679 - case 0x4c: 680 - /* 681 - * Recovered Check-One failure. Cu develops a hardware error, 682 - * but is able to recover. 683 - */ 684 - return tape_34xx_erp_retry(request); 685 - case 0x4d: 686 - if (device->cdev->id.driver_info == tape_3490) 687 - /* 688 - * Resetting event received. Since the driver does 689 - * not support resetting event recovery (which has to 690 - * be handled by the I/O Layer), retry our command. 691 - */ 692 - return tape_34xx_erp_retry(request); 693 - /* This erpa is reserved for 3480. */ 694 - return tape_34xx_erp_bug(device, request, irb, sense[3]); 695 - case 0x4e: 696 - if (device->cdev->id.driver_info == tape_3490) { 697 - /* 698 - * Maximum block size exceeded. This indicates, that 699 - * the block to be written is larger than allowed for 700 - * buffered mode. 701 - */ 702 - dev_warn (&device->cdev->dev, "The maximum block size" 703 - " for buffered mode is exceeded\n"); 704 - return tape_34xx_erp_failed(request, -ENOBUFS); 705 - } 706 - /* This erpa is reserved for 3480. */ 707 - return tape_34xx_erp_bug(device, request, irb, sense[3]); 708 - case 0x50: 709 - /* 710 - * Read buffered log (Overflow). CU is running in extended 711 - * buffered log mode, and a counter overflows. This should 712 - * never happen, since we're never running in extended 713 - * buffered log mode. 714 - */ 715 - return tape_34xx_erp_retry(request); 716 - case 0x51: 717 - /* 718 - * Read buffered log (EOV). EOF processing occurs while the 719 - * CU is in extended buffered log mode. This should never 720 - * happen, since we're never running in extended buffered 721 - * log mode. 722 - */ 723 - return tape_34xx_erp_retry(request); 724 - case 0x52: 725 - /* End of Volume complete. Rewind unload completed ok. */ 726 - if (request->op == TO_RUN) { 727 - tape_med_state_set(device, MS_UNLOADED); 728 - tape_34xx_delete_sbid_from(device, 0); 729 - return tape_34xx_erp_succeeded(request); 730 - } 731 - return tape_34xx_erp_bug(device, request, irb, sense[3]); 732 - case 0x53: 733 - /* Global command intercept. */ 734 - return tape_34xx_erp_retry(request); 735 - case 0x54: 736 - /* Channel interface recovery (temporary). */ 737 - return tape_34xx_erp_retry(request); 738 - case 0x55: 739 - /* Channel interface recovery (permanent). */ 740 - dev_warn (&device->cdev->dev, "A channel interface error cannot be" 741 - " recovered\n"); 742 - return tape_34xx_erp_failed(request, -EIO); 743 - case 0x56: 744 - /* Channel protocol error. */ 745 - dev_warn (&device->cdev->dev, "A channel protocol error " 746 - "occurred\n"); 747 - return tape_34xx_erp_failed(request, -EIO); 748 - case 0x57: 749 - /* 750 - * 3480: Attention intercept. 751 - * 3490: Global status intercept. 752 - */ 753 - return tape_34xx_erp_retry(request); 754 - case 0x5a: 755 - /* 756 - * Tape length incompatible. The tape inserted is too long, 757 - * which could cause damage to the tape or the drive. 758 - */ 759 - dev_warn (&device->cdev->dev, "The tape unit does not support " 760 - "the tape length\n"); 761 - return tape_34xx_erp_failed(request, -EIO); 762 - case 0x5b: 763 - /* Format 3480 XF incompatible */ 764 - if (sense[1] & SENSE_BEGINNING_OF_TAPE) 765 - /* The tape will get overwritten. */ 766 - return tape_34xx_erp_retry(request); 767 - dev_warn (&device->cdev->dev, "The tape unit does not support" 768 - " format 3480 XF\n"); 769 - return tape_34xx_erp_failed(request, -EIO); 770 - case 0x5c: 771 - /* Format 3480-2 XF incompatible */ 772 - dev_warn (&device->cdev->dev, "The tape unit does not support tape " 773 - "format 3480-2 XF\n"); 774 - return tape_34xx_erp_failed(request, -EIO); 775 - case 0x5d: 776 - /* Tape length violation. */ 777 - dev_warn (&device->cdev->dev, "The tape unit does not support" 778 - " the current tape length\n"); 779 - return tape_34xx_erp_failed(request, -EMEDIUMTYPE); 780 - case 0x5e: 781 - /* Compaction algorithm incompatible. */ 782 - dev_warn (&device->cdev->dev, "The tape unit does not support" 783 - " the compaction algorithm\n"); 784 - return tape_34xx_erp_failed(request, -EMEDIUMTYPE); 785 - 786 - /* The following erpas should have been covered earlier. */ 787 - case 0x23: /* Read data check. */ 788 - case 0x25: /* Write data check. */ 789 - case 0x26: /* Data check (read opposite). */ 790 - case 0x28: /* Write id mark check. */ 791 - case 0x31: /* Tape void. */ 792 - case 0x40: /* Overrun error. */ 793 - case 0x41: /* Record sequence error. */ 794 - /* All other erpas are reserved for future use. */ 795 - default: 796 - return tape_34xx_erp_bug(device, request, irb, sense[3]); 797 - } 798 - } 799 - 800 - /* 801 - * 3480/3490 interrupt handler 802 - */ 803 - static int 804 - tape_34xx_irq(struct tape_device *device, struct tape_request *request, 805 - struct irb *irb) 806 - { 807 - if (request == NULL) 808 - return tape_34xx_unsolicited_irq(device, irb); 809 - 810 - if ((irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) && 811 - (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) && 812 - (request->op == TO_WRI)) { 813 - /* Write at end of volume */ 814 - return tape_34xx_erp_failed(request, -ENOSPC); 815 - } 816 - 817 - if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) 818 - return tape_34xx_unit_check(device, request, irb); 819 - 820 - if (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) { 821 - /* 822 - * A unit exception occurs on skipping over a tapemark block. 823 - */ 824 - if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) { 825 - if (request->op == TO_BSB || request->op == TO_FSB) 826 - request->rescnt++; 827 - else 828 - DBF_EVENT(5, "Unit Exception!\n"); 829 - } 830 - return tape_34xx_done(request); 831 - } 832 - 833 - DBF_EVENT(6, "xunknownirq\n"); 834 - tape_dump_sense_dbf(device, request, irb); 835 - return TAPE_IO_STOP; 836 - } 837 - 838 - /* 839 - * ioctl_overload 840 - */ 841 - static int 842 - tape_34xx_ioctl(struct tape_device *device, unsigned int cmd, unsigned long arg) 843 - { 844 - if (cmd == TAPE390_DISPLAY) { 845 - struct display_struct disp; 846 - 847 - if (copy_from_user(&disp, (char __user *) arg, sizeof(disp)) != 0) 848 - return -EFAULT; 849 - 850 - return tape_std_display(device, &disp); 851 - } else 852 - return -EINVAL; 853 - } 854 - 855 - static inline void 856 - tape_34xx_append_new_sbid(struct tape_34xx_block_id bid, struct list_head *l) 857 - { 858 - struct tape_34xx_sbid * new_sbid; 859 - 860 - new_sbid = kmalloc(sizeof(*new_sbid), GFP_ATOMIC); 861 - if (!new_sbid) 862 - return; 863 - 864 - new_sbid->bid = bid; 865 - list_add(&new_sbid->list, l); 866 - } 867 - 868 - /* 869 - * Build up the search block ID list. The block ID consists of a logical 870 - * block number and a hardware specific part. The hardware specific part 871 - * helps the tape drive to speed up searching for a specific block. 872 - */ 873 - static void 874 - tape_34xx_add_sbid(struct tape_device *device, struct tape_34xx_block_id bid) 875 - { 876 - struct list_head * sbid_list; 877 - struct tape_34xx_sbid * sbid; 878 - struct list_head * l; 879 - 880 - /* 881 - * immediately return if there is no list at all or the block to add 882 - * is located in segment 1 of wrap 0 because this position is used 883 - * if no hardware position data is supplied. 884 - */ 885 - sbid_list = (struct list_head *) device->discdata; 886 - if (!sbid_list || (bid.segment < 2 && bid.wrap == 0)) 887 - return; 888 - 889 - /* 890 - * Search the position where to insert the new entry. Hardware 891 - * acceleration uses only the segment and wrap number. So we 892 - * need only one entry for a specific wrap/segment combination. 893 - * If there is a block with a lower number but the same hard- 894 - * ware position data we just update the block number in the 895 - * existing entry. 896 - */ 897 - list_for_each(l, sbid_list) { 898 - sbid = list_entry(l, struct tape_34xx_sbid, list); 899 - 900 - if ( 901 - (sbid->bid.segment == bid.segment) && 902 - (sbid->bid.wrap == bid.wrap) 903 - ) { 904 - if (bid.block < sbid->bid.block) 905 - sbid->bid = bid; 906 - else return; 907 - break; 908 - } 909 - 910 - /* Sort in according to logical block number. */ 911 - if (bid.block < sbid->bid.block) { 912 - tape_34xx_append_new_sbid(bid, l->prev); 913 - break; 914 - } 915 - } 916 - /* List empty or new block bigger than last entry. */ 917 - if (l == sbid_list) 918 - tape_34xx_append_new_sbid(bid, l->prev); 919 - 920 - DBF_LH(4, "Current list is:\n"); 921 - list_for_each(l, sbid_list) { 922 - sbid = list_entry(l, struct tape_34xx_sbid, list); 923 - DBF_LH(4, "%d:%03d@%05d\n", 924 - sbid->bid.wrap, 925 - sbid->bid.segment, 926 - sbid->bid.block 927 - ); 928 - } 929 - } 930 - 931 - /* 932 - * Delete all entries from the search block ID list that belong to tape blocks 933 - * equal or higher than the given number. 934 - */ 935 - static void 936 - tape_34xx_delete_sbid_from(struct tape_device *device, int from) 937 - { 938 - struct list_head * sbid_list; 939 - struct tape_34xx_sbid * sbid; 940 - struct list_head * l; 941 - struct list_head * n; 942 - 943 - sbid_list = (struct list_head *) device->discdata; 944 - if (!sbid_list) 945 - return; 946 - 947 - list_for_each_safe(l, n, sbid_list) { 948 - sbid = list_entry(l, struct tape_34xx_sbid, list); 949 - if (sbid->bid.block >= from) { 950 - DBF_LH(4, "Delete sbid %d:%03d@%05d\n", 951 - sbid->bid.wrap, 952 - sbid->bid.segment, 953 - sbid->bid.block 954 - ); 955 - list_del(l); 956 - kfree(sbid); 957 - } 958 - } 959 - } 960 - 961 - /* 962 - * Merge hardware position data into a block id. 963 - */ 964 - static void 965 - tape_34xx_merge_sbid( 966 - struct tape_device * device, 967 - struct tape_34xx_block_id * bid 968 - ) { 969 - struct tape_34xx_sbid * sbid; 970 - struct tape_34xx_sbid * sbid_to_use; 971 - struct list_head * sbid_list; 972 - struct list_head * l; 973 - 974 - sbid_list = (struct list_head *) device->discdata; 975 - bid->wrap = 0; 976 - bid->segment = 1; 977 - 978 - if (!sbid_list || list_empty(sbid_list)) 979 - return; 980 - 981 - sbid_to_use = NULL; 982 - list_for_each(l, sbid_list) { 983 - sbid = list_entry(l, struct tape_34xx_sbid, list); 984 - 985 - if (sbid->bid.block >= bid->block) 986 - break; 987 - sbid_to_use = sbid; 988 - } 989 - if (sbid_to_use) { 990 - bid->wrap = sbid_to_use->bid.wrap; 991 - bid->segment = sbid_to_use->bid.segment; 992 - DBF_LH(4, "Use %d:%03d@%05d for %05d\n", 993 - sbid_to_use->bid.wrap, 994 - sbid_to_use->bid.segment, 995 - sbid_to_use->bid.block, 996 - bid->block 997 - ); 998 - } 999 - } 1000 - 1001 - static int 1002 - tape_34xx_setup_device(struct tape_device * device) 1003 - { 1004 - int rc; 1005 - struct list_head * discdata; 1006 - 1007 - DBF_EVENT(6, "34xx device setup\n"); 1008 - if ((rc = tape_std_assign(device)) == 0) { 1009 - if ((rc = tape_34xx_medium_sense(device)) != 0) { 1010 - DBF_LH(3, "34xx medium sense returned %d\n", rc); 1011 - } 1012 - } 1013 - discdata = kmalloc(sizeof(struct list_head), GFP_KERNEL); 1014 - if (discdata) { 1015 - INIT_LIST_HEAD(discdata); 1016 - device->discdata = discdata; 1017 - } 1018 - 1019 - return rc; 1020 - } 1021 - 1022 - static void 1023 - tape_34xx_cleanup_device(struct tape_device *device) 1024 - { 1025 - tape_std_unassign(device); 1026 - 1027 - if (device->discdata) { 1028 - tape_34xx_delete_sbid_from(device, 0); 1029 - kfree(device->discdata); 1030 - device->discdata = NULL; 1031 - } 1032 - } 1033 - 1034 - 1035 - /* 1036 - * MTTELL: Tell block. Return the number of block relative to current file. 1037 - */ 1038 - static int 1039 - tape_34xx_mttell(struct tape_device *device, int mt_count) 1040 - { 1041 - struct { 1042 - struct tape_34xx_block_id cbid; 1043 - struct tape_34xx_block_id dbid; 1044 - } __attribute__ ((packed)) block_id; 1045 - int rc; 1046 - 1047 - rc = tape_std_read_block_id(device, (__u64 *) &block_id); 1048 - if (rc) 1049 - return rc; 1050 - 1051 - tape_34xx_add_sbid(device, block_id.cbid); 1052 - return block_id.cbid.block; 1053 - } 1054 - 1055 - /* 1056 - * MTSEEK: seek to the specified block. 1057 - */ 1058 - static int 1059 - tape_34xx_mtseek(struct tape_device *device, int mt_count) 1060 - { 1061 - struct tape_request *request; 1062 - struct tape_34xx_block_id * bid; 1063 - 1064 - if (mt_count > 0x3fffff) { 1065 - DBF_EXCEPTION(6, "xsee parm\n"); 1066 - return -EINVAL; 1067 - } 1068 - request = tape_alloc_request(3, 4); 1069 - if (IS_ERR(request)) 1070 - return PTR_ERR(request); 1071 - 1072 - /* setup ccws */ 1073 - request->op = TO_LBL; 1074 - bid = (struct tape_34xx_block_id *) request->cpdata; 1075 - bid->format = (*device->modeset_byte & 0x08) ? 1076 - TAPE34XX_FMT_3480_XF : TAPE34XX_FMT_3480; 1077 - bid->block = mt_count; 1078 - tape_34xx_merge_sbid(device, bid); 1079 - 1080 - tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); 1081 - tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata); 1082 - tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL); 1083 - 1084 - /* execute it */ 1085 - return tape_do_io_free(device, request); 1086 - } 1087 - 1088 - /* 1089 - * List of 3480/3490 magnetic tape commands. 1090 - */ 1091 - static tape_mtop_fn tape_34xx_mtop[TAPE_NR_MTOPS] = { 1092 - [MTRESET] = tape_std_mtreset, 1093 - [MTFSF] = tape_std_mtfsf, 1094 - [MTBSF] = tape_std_mtbsf, 1095 - [MTFSR] = tape_std_mtfsr, 1096 - [MTBSR] = tape_std_mtbsr, 1097 - [MTWEOF] = tape_std_mtweof, 1098 - [MTREW] = tape_std_mtrew, 1099 - [MTOFFL] = tape_std_mtoffl, 1100 - [MTNOP] = tape_std_mtnop, 1101 - [MTRETEN] = tape_std_mtreten, 1102 - [MTBSFM] = tape_std_mtbsfm, 1103 - [MTFSFM] = tape_std_mtfsfm, 1104 - [MTEOM] = tape_std_mteom, 1105 - [MTERASE] = tape_std_mterase, 1106 - [MTRAS1] = NULL, 1107 - [MTRAS2] = NULL, 1108 - [MTRAS3] = NULL, 1109 - [MTSETBLK] = tape_std_mtsetblk, 1110 - [MTSETDENSITY] = NULL, 1111 - [MTSEEK] = tape_34xx_mtseek, 1112 - [MTTELL] = tape_34xx_mttell, 1113 - [MTSETDRVBUFFER] = NULL, 1114 - [MTFSS] = NULL, 1115 - [MTBSS] = NULL, 1116 - [MTWSM] = NULL, 1117 - [MTLOCK] = NULL, 1118 - [MTUNLOCK] = NULL, 1119 - [MTLOAD] = tape_std_mtload, 1120 - [MTUNLOAD] = tape_std_mtunload, 1121 - [MTCOMPRESSION] = tape_std_mtcompression, 1122 - [MTSETPART] = NULL, 1123 - [MTMKPART] = NULL 1124 - }; 1125 - 1126 - /* 1127 - * Tape discipline structure for 3480 and 3490. 1128 - */ 1129 - static struct tape_discipline tape_discipline_34xx = { 1130 - .owner = THIS_MODULE, 1131 - .setup_device = tape_34xx_setup_device, 1132 - .cleanup_device = tape_34xx_cleanup_device, 1133 - .process_eov = tape_std_process_eov, 1134 - .irq = tape_34xx_irq, 1135 - .read_block = tape_std_read_block, 1136 - .write_block = tape_std_write_block, 1137 - .ioctl_fn = tape_34xx_ioctl, 1138 - .mtop_array = tape_34xx_mtop 1139 - }; 1140 - 1141 - static struct ccw_device_id tape_34xx_ids[] = { 1142 - { CCW_DEVICE_DEVTYPE(0x3480, 0, 0x3480, 0), .driver_info = tape_3480}, 1143 - { CCW_DEVICE_DEVTYPE(0x3490, 0, 0x3490, 0), .driver_info = tape_3490}, 1144 - { /* end of list */ }, 1145 - }; 1146 - 1147 - static int 1148 - tape_34xx_online(struct ccw_device *cdev) 1149 - { 1150 - return tape_generic_online( 1151 - dev_get_drvdata(&cdev->dev), 1152 - &tape_discipline_34xx 1153 - ); 1154 - } 1155 - 1156 - static struct ccw_driver tape_34xx_driver = { 1157 - .driver = { 1158 - .name = "tape_34xx", 1159 - .owner = THIS_MODULE, 1160 - }, 1161 - .ids = tape_34xx_ids, 1162 - .probe = tape_generic_probe, 1163 - .remove = tape_generic_remove, 1164 - .set_online = tape_34xx_online, 1165 - .set_offline = tape_generic_offline, 1166 - .int_class = IRQIO_TAP, 1167 - }; 1168 - 1169 - static int 1170 - tape_34xx_init (void) 1171 - { 1172 - int rc; 1173 - 1174 - TAPE_DBF_AREA = debug_register ( "tape_34xx", 2, 2, 4*sizeof(long)); 1175 - debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view); 1176 - #ifdef DBF_LIKE_HELL 1177 - debug_set_level(TAPE_DBF_AREA, 6); 1178 - #endif 1179 - 1180 - DBF_EVENT(3, "34xx init\n"); 1181 - /* Register driver for 3480/3490 tapes. */ 1182 - rc = ccw_driver_register(&tape_34xx_driver); 1183 - if (rc) 1184 - DBF_EVENT(3, "34xx init failed\n"); 1185 - else 1186 - DBF_EVENT(3, "34xx registered\n"); 1187 - return rc; 1188 - } 1189 - 1190 - static void 1191 - tape_34xx_exit(void) 1192 - { 1193 - ccw_driver_unregister(&tape_34xx_driver); 1194 - 1195 - debug_unregister(TAPE_DBF_AREA); 1196 - } 1197 - 1198 - MODULE_DEVICE_TABLE(ccw, tape_34xx_ids); 1199 - MODULE_AUTHOR("(C) 2001-2002 IBM Deutschland Entwicklung GmbH"); 1200 - MODULE_DESCRIPTION("Linux on zSeries channel attached 3480 tape device driver"); 1201 - MODULE_LICENSE("GPL"); 1202 - 1203 - module_init(tape_34xx_init); 1204 - module_exit(tape_34xx_exit);
-1612
drivers/s390/char/tape_3590.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * tape device discipline for 3590 tapes. 4 - * 5 - * Copyright IBM Corp. 2001, 2009 6 - * Author(s): Stefan Bader <shbader@de.ibm.com> 7 - * Michael Holzheu <holzheu@de.ibm.com> 8 - * Martin Schwidefsky <schwidefsky@de.ibm.com> 9 - */ 10 - 11 - #define pr_fmt(fmt) "tape_3590: " fmt 12 - 13 - #include <linux/export.h> 14 - #include <linux/module.h> 15 - #include <linux/slab.h> 16 - #include <linux/init.h> 17 - #include <linux/bio.h> 18 - #include <asm/ebcdic.h> 19 - 20 - #define TAPE_DBF_AREA tape_3590_dbf 21 - #define BUFSIZE 512 /* size of buffers for dynamic generated messages */ 22 - 23 - #include "tape.h" 24 - #include "tape_std.h" 25 - #include "tape_3590.h" 26 - 27 - static struct workqueue_struct *tape_3590_wq; 28 - 29 - /* 30 - * Pointer to debug area. 31 - */ 32 - debug_info_t *TAPE_DBF_AREA = NULL; 33 - EXPORT_SYMBOL(TAPE_DBF_AREA); 34 - 35 - /******************************************************************* 36 - * Error Recovery functions: 37 - * - Read Opposite: implemented 38 - * - Read Device (buffered) log: BRA 39 - * - Read Library log: BRA 40 - * - Swap Devices: BRA 41 - * - Long Busy: implemented 42 - * - Special Intercept: BRA 43 - * - Read Alternate: implemented 44 - *******************************************************************/ 45 - 46 - static const char *tape_3590_msg[TAPE_3590_MAX_MSG] = { 47 - [0x00] = "", 48 - [0x10] = "Lost Sense", 49 - [0x11] = "Assigned Elsewhere", 50 - [0x12] = "Allegiance Reset", 51 - [0x13] = "Shared Access Violation", 52 - [0x20] = "Command Reject", 53 - [0x21] = "Configuration Error", 54 - [0x22] = "Protection Exception", 55 - [0x23] = "Write Protect", 56 - [0x24] = "Write Length", 57 - [0x25] = "Read-Only Format", 58 - [0x31] = "Beginning of Partition", 59 - [0x33] = "End of Partition", 60 - [0x34] = "End of Data", 61 - [0x35] = "Block not found", 62 - [0x40] = "Device Intervention", 63 - [0x41] = "Loader Intervention", 64 - [0x42] = "Library Intervention", 65 - [0x50] = "Write Error", 66 - [0x51] = "Erase Error", 67 - [0x52] = "Formatting Error", 68 - [0x53] = "Read Error", 69 - [0x54] = "Unsupported Format", 70 - [0x55] = "No Formatting", 71 - [0x56] = "Positioning lost", 72 - [0x57] = "Read Length", 73 - [0x60] = "Unsupported Medium", 74 - [0x61] = "Medium Length Error", 75 - [0x62] = "Medium removed", 76 - [0x64] = "Load Check", 77 - [0x65] = "Unload Check", 78 - [0x70] = "Equipment Check", 79 - [0x71] = "Bus out Check", 80 - [0x72] = "Protocol Error", 81 - [0x73] = "Interface Error", 82 - [0x74] = "Overrun", 83 - [0x75] = "Halt Signal", 84 - [0x90] = "Device fenced", 85 - [0x91] = "Device Path fenced", 86 - [0xa0] = "Volume misplaced", 87 - [0xa1] = "Volume inaccessible", 88 - [0xa2] = "Volume in input", 89 - [0xa3] = "Volume ejected", 90 - [0xa4] = "All categories reserved", 91 - [0xa5] = "Duplicate Volume", 92 - [0xa6] = "Library Manager Offline", 93 - [0xa7] = "Library Output Station full", 94 - [0xa8] = "Vision System non-operational", 95 - [0xa9] = "Library Manager Equipment Check", 96 - [0xaa] = "Library Equipment Check", 97 - [0xab] = "All Library Cells full", 98 - [0xac] = "No Cleaner Volumes in Library", 99 - [0xad] = "I/O Station door open", 100 - [0xae] = "Subsystem environmental alert", 101 - }; 102 - 103 - static int crypt_supported(struct tape_device *device) 104 - { 105 - return TAPE390_CRYPT_SUPPORTED(TAPE_3590_CRYPT_INFO(device)); 106 - } 107 - 108 - static int crypt_enabled(struct tape_device *device) 109 - { 110 - return TAPE390_CRYPT_ON(TAPE_3590_CRYPT_INFO(device)); 111 - } 112 - 113 - static void ext_to_int_kekl(struct tape390_kekl *in, 114 - struct tape3592_kekl *out) 115 - { 116 - int len; 117 - 118 - memset(out, 0, sizeof(*out)); 119 - if (in->type == TAPE390_KEKL_TYPE_HASH) 120 - out->flags |= 0x40; 121 - if (in->type_on_tape == TAPE390_KEKL_TYPE_HASH) 122 - out->flags |= 0x80; 123 - len = min(sizeof(out->label), strlen(in->label)); 124 - memcpy(out->label, in->label, len); 125 - memset(out->label + len, ' ', sizeof(out->label) - len); 126 - ASCEBC(out->label, sizeof(out->label)); 127 - } 128 - 129 - static void int_to_ext_kekl(struct tape3592_kekl *in, 130 - struct tape390_kekl *out) 131 - { 132 - memset(out, 0, sizeof(*out)); 133 - if(in->flags & 0x40) 134 - out->type = TAPE390_KEKL_TYPE_HASH; 135 - else 136 - out->type = TAPE390_KEKL_TYPE_LABEL; 137 - if(in->flags & 0x80) 138 - out->type_on_tape = TAPE390_KEKL_TYPE_HASH; 139 - else 140 - out->type_on_tape = TAPE390_KEKL_TYPE_LABEL; 141 - memcpy(out->label, in->label, sizeof(in->label)); 142 - EBCASC(out->label, sizeof(in->label)); 143 - strim(out->label); 144 - } 145 - 146 - static void int_to_ext_kekl_pair(struct tape3592_kekl_pair *in, 147 - struct tape390_kekl_pair *out) 148 - { 149 - if (in->count == 0) { 150 - out->kekl[0].type = TAPE390_KEKL_TYPE_NONE; 151 - out->kekl[0].type_on_tape = TAPE390_KEKL_TYPE_NONE; 152 - out->kekl[1].type = TAPE390_KEKL_TYPE_NONE; 153 - out->kekl[1].type_on_tape = TAPE390_KEKL_TYPE_NONE; 154 - } else if (in->count == 1) { 155 - int_to_ext_kekl(&in->kekl[0], &out->kekl[0]); 156 - out->kekl[1].type = TAPE390_KEKL_TYPE_NONE; 157 - out->kekl[1].type_on_tape = TAPE390_KEKL_TYPE_NONE; 158 - } else if (in->count == 2) { 159 - int_to_ext_kekl(&in->kekl[0], &out->kekl[0]); 160 - int_to_ext_kekl(&in->kekl[1], &out->kekl[1]); 161 - } else { 162 - printk("Invalid KEKL number: %d\n", in->count); 163 - BUG(); 164 - } 165 - } 166 - 167 - static int check_ext_kekl(struct tape390_kekl *kekl) 168 - { 169 - if (kekl->type == TAPE390_KEKL_TYPE_NONE) 170 - goto invalid; 171 - if (kekl->type > TAPE390_KEKL_TYPE_HASH) 172 - goto invalid; 173 - if (kekl->type_on_tape == TAPE390_KEKL_TYPE_NONE) 174 - goto invalid; 175 - if (kekl->type_on_tape > TAPE390_KEKL_TYPE_HASH) 176 - goto invalid; 177 - if ((kekl->type == TAPE390_KEKL_TYPE_HASH) && 178 - (kekl->type_on_tape == TAPE390_KEKL_TYPE_LABEL)) 179 - goto invalid; 180 - 181 - return 0; 182 - invalid: 183 - return -EINVAL; 184 - } 185 - 186 - static int check_ext_kekl_pair(struct tape390_kekl_pair *kekls) 187 - { 188 - if (check_ext_kekl(&kekls->kekl[0])) 189 - goto invalid; 190 - if (check_ext_kekl(&kekls->kekl[1])) 191 - goto invalid; 192 - 193 - return 0; 194 - invalid: 195 - return -EINVAL; 196 - } 197 - 198 - /* 199 - * Query KEKLs 200 - */ 201 - static int tape_3592_kekl_query(struct tape_device *device, 202 - struct tape390_kekl_pair *ext_kekls) 203 - { 204 - struct tape_request *request; 205 - struct tape3592_kekl_query_order *order; 206 - struct tape3592_kekl_query_data *int_kekls; 207 - int rc; 208 - 209 - DBF_EVENT(6, "tape3592_kekl_query\n"); 210 - int_kekls = kmalloc(sizeof(*int_kekls), GFP_KERNEL|GFP_DMA); 211 - if (!int_kekls) 212 - return -ENOMEM; 213 - request = tape_alloc_request(2, sizeof(*order)); 214 - if (IS_ERR(request)) { 215 - rc = PTR_ERR(request); 216 - goto fail_malloc; 217 - } 218 - order = request->cpdata; 219 - memset(order,0,sizeof(*order)); 220 - order->code = 0xe2; 221 - order->max_count = 2; 222 - request->op = TO_KEKL_QUERY; 223 - tape_ccw_cc(request->cpaddr, PERF_SUBSYS_FUNC, sizeof(*order), order); 224 - tape_ccw_end(request->cpaddr + 1, READ_SS_DATA, sizeof(*int_kekls), 225 - int_kekls); 226 - rc = tape_do_io(device, request); 227 - if (rc) 228 - goto fail_request; 229 - int_to_ext_kekl_pair(&int_kekls->kekls, ext_kekls); 230 - 231 - rc = 0; 232 - fail_request: 233 - tape_free_request(request); 234 - fail_malloc: 235 - kfree(int_kekls); 236 - return rc; 237 - } 238 - 239 - /* 240 - * IOCTL: Query KEKLs 241 - */ 242 - static int tape_3592_ioctl_kekl_query(struct tape_device *device, 243 - unsigned long arg) 244 - { 245 - int rc; 246 - struct tape390_kekl_pair *ext_kekls; 247 - 248 - DBF_EVENT(6, "tape_3592_ioctl_kekl_query\n"); 249 - if (!crypt_supported(device)) 250 - return -ENOSYS; 251 - if (!crypt_enabled(device)) 252 - return -EUNATCH; 253 - ext_kekls = kmalloc(sizeof(*ext_kekls), GFP_KERNEL); 254 - if (!ext_kekls) 255 - return -ENOMEM; 256 - rc = tape_3592_kekl_query(device, ext_kekls); 257 - if (rc != 0) 258 - goto fail; 259 - if (copy_to_user((char __user *) arg, ext_kekls, sizeof(*ext_kekls))) { 260 - rc = -EFAULT; 261 - goto fail; 262 - } 263 - rc = 0; 264 - fail: 265 - kfree(ext_kekls); 266 - return rc; 267 - } 268 - 269 - static int tape_3590_mttell(struct tape_device *device, int mt_count); 270 - 271 - /* 272 - * Set KEKLs 273 - */ 274 - static int tape_3592_kekl_set(struct tape_device *device, 275 - struct tape390_kekl_pair *ext_kekls) 276 - { 277 - struct tape_request *request; 278 - struct tape3592_kekl_set_order *order; 279 - 280 - DBF_EVENT(6, "tape3592_kekl_set\n"); 281 - if (check_ext_kekl_pair(ext_kekls)) { 282 - DBF_EVENT(6, "invalid kekls\n"); 283 - return -EINVAL; 284 - } 285 - if (tape_3590_mttell(device, 0) != 0) 286 - return -EBADSLT; 287 - request = tape_alloc_request(1, sizeof(*order)); 288 - if (IS_ERR(request)) 289 - return PTR_ERR(request); 290 - order = request->cpdata; 291 - memset(order, 0, sizeof(*order)); 292 - order->code = 0xe3; 293 - order->kekls.count = 2; 294 - ext_to_int_kekl(&ext_kekls->kekl[0], &order->kekls.kekl[0]); 295 - ext_to_int_kekl(&ext_kekls->kekl[1], &order->kekls.kekl[1]); 296 - request->op = TO_KEKL_SET; 297 - tape_ccw_end(request->cpaddr, PERF_SUBSYS_FUNC, sizeof(*order), order); 298 - 299 - return tape_do_io_free(device, request); 300 - } 301 - 302 - /* 303 - * IOCTL: Set KEKLs 304 - */ 305 - static int tape_3592_ioctl_kekl_set(struct tape_device *device, 306 - unsigned long arg) 307 - { 308 - int rc; 309 - struct tape390_kekl_pair *ext_kekls; 310 - 311 - DBF_EVENT(6, "tape_3592_ioctl_kekl_set\n"); 312 - if (!crypt_supported(device)) 313 - return -ENOSYS; 314 - if (!crypt_enabled(device)) 315 - return -EUNATCH; 316 - ext_kekls = memdup_user((char __user *)arg, sizeof(*ext_kekls)); 317 - if (IS_ERR(ext_kekls)) 318 - return PTR_ERR(ext_kekls); 319 - rc = tape_3592_kekl_set(device, ext_kekls); 320 - kfree(ext_kekls); 321 - return rc; 322 - } 323 - 324 - /* 325 - * Enable encryption 326 - */ 327 - static struct tape_request *__tape_3592_enable_crypt(struct tape_device *device) 328 - { 329 - struct tape_request *request; 330 - char *data; 331 - 332 - DBF_EVENT(6, "tape_3592_enable_crypt\n"); 333 - if (!crypt_supported(device)) 334 - return ERR_PTR(-ENOSYS); 335 - request = tape_alloc_request(2, 72); 336 - if (IS_ERR(request)) 337 - return request; 338 - data = request->cpdata; 339 - memset(data,0,72); 340 - 341 - data[0] = 0x05; 342 - data[36 + 0] = 0x03; 343 - data[36 + 1] = 0x03; 344 - data[36 + 4] = 0x40; 345 - data[36 + 6] = 0x01; 346 - data[36 + 14] = 0x2f; 347 - data[36 + 18] = 0xc3; 348 - data[36 + 35] = 0x72; 349 - request->op = TO_CRYPT_ON; 350 - tape_ccw_cc(request->cpaddr, MODE_SET_CB, 36, data); 351 - tape_ccw_end(request->cpaddr + 1, MODE_SET_CB, 36, data + 36); 352 - return request; 353 - } 354 - 355 - static int tape_3592_enable_crypt(struct tape_device *device) 356 - { 357 - struct tape_request *request; 358 - 359 - request = __tape_3592_enable_crypt(device); 360 - if (IS_ERR(request)) 361 - return PTR_ERR(request); 362 - return tape_do_io_free(device, request); 363 - } 364 - 365 - static void tape_3592_enable_crypt_async(struct tape_device *device) 366 - { 367 - struct tape_request *request; 368 - 369 - request = __tape_3592_enable_crypt(device); 370 - if (!IS_ERR(request)) 371 - tape_do_io_async_free(device, request); 372 - } 373 - 374 - /* 375 - * Disable encryption 376 - */ 377 - static struct tape_request *__tape_3592_disable_crypt(struct tape_device *device) 378 - { 379 - struct tape_request *request; 380 - char *data; 381 - 382 - DBF_EVENT(6, "tape_3592_disable_crypt\n"); 383 - if (!crypt_supported(device)) 384 - return ERR_PTR(-ENOSYS); 385 - request = tape_alloc_request(2, 72); 386 - if (IS_ERR(request)) 387 - return request; 388 - data = request->cpdata; 389 - memset(data,0,72); 390 - 391 - data[0] = 0x05; 392 - data[36 + 0] = 0x03; 393 - data[36 + 1] = 0x03; 394 - data[36 + 35] = 0x32; 395 - 396 - request->op = TO_CRYPT_OFF; 397 - tape_ccw_cc(request->cpaddr, MODE_SET_CB, 36, data); 398 - tape_ccw_end(request->cpaddr + 1, MODE_SET_CB, 36, data + 36); 399 - 400 - return request; 401 - } 402 - 403 - static int tape_3592_disable_crypt(struct tape_device *device) 404 - { 405 - struct tape_request *request; 406 - 407 - request = __tape_3592_disable_crypt(device); 408 - if (IS_ERR(request)) 409 - return PTR_ERR(request); 410 - return tape_do_io_free(device, request); 411 - } 412 - 413 - static void tape_3592_disable_crypt_async(struct tape_device *device) 414 - { 415 - struct tape_request *request; 416 - 417 - request = __tape_3592_disable_crypt(device); 418 - if (!IS_ERR(request)) 419 - tape_do_io_async_free(device, request); 420 - } 421 - 422 - /* 423 - * IOCTL: Set encryption status 424 - */ 425 - static int tape_3592_ioctl_crypt_set(struct tape_device *device, 426 - unsigned long arg) 427 - { 428 - struct tape390_crypt_info info; 429 - 430 - DBF_EVENT(6, "tape_3592_ioctl_crypt_set\n"); 431 - if (!crypt_supported(device)) 432 - return -ENOSYS; 433 - if (copy_from_user(&info, (char __user *)arg, sizeof(info))) 434 - return -EFAULT; 435 - if (info.status & ~TAPE390_CRYPT_ON_MASK) 436 - return -EINVAL; 437 - if (info.status & TAPE390_CRYPT_ON_MASK) 438 - return tape_3592_enable_crypt(device); 439 - else 440 - return tape_3592_disable_crypt(device); 441 - } 442 - 443 - static int tape_3590_sense_medium(struct tape_device *device); 444 - 445 - /* 446 - * IOCTL: Query enryption status 447 - */ 448 - static int tape_3592_ioctl_crypt_query(struct tape_device *device, 449 - unsigned long arg) 450 - { 451 - DBF_EVENT(6, "tape_3592_ioctl_crypt_query\n"); 452 - if (!crypt_supported(device)) 453 - return -ENOSYS; 454 - tape_3590_sense_medium(device); 455 - if (copy_to_user((char __user *) arg, &TAPE_3590_CRYPT_INFO(device), 456 - sizeof(TAPE_3590_CRYPT_INFO(device)))) 457 - return -EFAULT; 458 - else 459 - return 0; 460 - } 461 - 462 - /* 463 - * 3590 IOCTL Overload 464 - */ 465 - static int 466 - tape_3590_ioctl(struct tape_device *device, unsigned int cmd, unsigned long arg) 467 - { 468 - switch (cmd) { 469 - case TAPE390_DISPLAY: { 470 - struct display_struct disp; 471 - 472 - if (copy_from_user(&disp, (char __user *) arg, sizeof(disp))) 473 - return -EFAULT; 474 - 475 - return tape_std_display(device, &disp); 476 - } 477 - case TAPE390_KEKL_SET: 478 - return tape_3592_ioctl_kekl_set(device, arg); 479 - case TAPE390_KEKL_QUERY: 480 - return tape_3592_ioctl_kekl_query(device, arg); 481 - case TAPE390_CRYPT_SET: 482 - return tape_3592_ioctl_crypt_set(device, arg); 483 - case TAPE390_CRYPT_QUERY: 484 - return tape_3592_ioctl_crypt_query(device, arg); 485 - default: 486 - return -EINVAL; /* no additional ioctls */ 487 - } 488 - } 489 - 490 - /* 491 - * SENSE Medium: Get Sense data about medium state 492 - */ 493 - static int tape_3590_sense_medium(struct tape_device *device) 494 - { 495 - struct tape_request *request; 496 - 497 - request = tape_alloc_request(1, 128); 498 - if (IS_ERR(request)) 499 - return PTR_ERR(request); 500 - request->op = TO_MSEN; 501 - tape_ccw_end(request->cpaddr, MEDIUM_SENSE, 128, request->cpdata); 502 - return tape_do_io_free(device, request); 503 - } 504 - 505 - static void tape_3590_sense_medium_async(struct tape_device *device) 506 - { 507 - struct tape_request *request; 508 - 509 - request = tape_alloc_request(1, 128); 510 - if (IS_ERR(request)) 511 - return; 512 - request->op = TO_MSEN; 513 - tape_ccw_end(request->cpaddr, MEDIUM_SENSE, 128, request->cpdata); 514 - tape_do_io_async_free(device, request); 515 - } 516 - 517 - /* 518 - * MTTELL: Tell block. Return the number of block relative to current file. 519 - */ 520 - static int 521 - tape_3590_mttell(struct tape_device *device, int mt_count) 522 - { 523 - __u64 block_id; 524 - int rc; 525 - 526 - rc = tape_std_read_block_id(device, &block_id); 527 - if (rc) 528 - return rc; 529 - return block_id >> 32; 530 - } 531 - 532 - /* 533 - * MTSEEK: seek to the specified block. 534 - */ 535 - static int 536 - tape_3590_mtseek(struct tape_device *device, int count) 537 - { 538 - struct tape_request *request; 539 - 540 - DBF_EVENT(6, "xsee id: %x\n", count); 541 - request = tape_alloc_request(3, 4); 542 - if (IS_ERR(request)) 543 - return PTR_ERR(request); 544 - request->op = TO_LBL; 545 - tape_ccw_cc(request->cpaddr, MODE_SET_DB, 1, device->modeset_byte); 546 - *(__u32 *) request->cpdata = count; 547 - tape_ccw_cc(request->cpaddr + 1, LOCATE, 4, request->cpdata); 548 - tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL); 549 - return tape_do_io_free(device, request); 550 - } 551 - 552 - /* 553 - * Read Attention Msg 554 - * This should be done after an interrupt with attention bit (0x80) 555 - * in device state. 556 - * 557 - * After a "read attention message" request there are two possible 558 - * results: 559 - * 560 - * 1. A unit check is presented, when attention sense is present (e.g. when 561 - * a medium has been unloaded). The attention sense comes then 562 - * together with the unit check. The recovery action is either "retry" 563 - * (in case there is an attention message pending) or "permanent error". 564 - * 565 - * 2. The attention msg is written to the "read subsystem data" buffer. 566 - * In this case we probably should print it to the console. 567 - */ 568 - static void tape_3590_read_attmsg_async(struct tape_device *device) 569 - { 570 - struct tape_request *request; 571 - char *buf; 572 - 573 - request = tape_alloc_request(3, 4096); 574 - if (IS_ERR(request)) 575 - return; 576 - request->op = TO_READ_ATTMSG; 577 - buf = request->cpdata; 578 - buf[0] = PREP_RD_SS_DATA; 579 - buf[6] = RD_ATTMSG; /* read att msg */ 580 - tape_ccw_cc(request->cpaddr, PERFORM_SS_FUNC, 12, buf); 581 - tape_ccw_cc(request->cpaddr + 1, READ_SS_DATA, 4096 - 12, buf + 12); 582 - tape_ccw_end(request->cpaddr + 2, NOP, 0, NULL); 583 - tape_do_io_async_free(device, request); 584 - } 585 - 586 - /* 587 - * These functions are used to schedule follow-up actions from within an 588 - * interrupt context (like unsolicited interrupts). 589 - * Note: the work handler is called by the system work queue. The tape 590 - * commands started by the handler need to be asynchrounous, otherwise 591 - * a deadlock can occur e.g. in case of a deferred cc=1 (see __tape_do_irq). 592 - */ 593 - struct work_handler_data { 594 - struct tape_device *device; 595 - enum tape_op op; 596 - struct work_struct work; 597 - }; 598 - 599 - static void 600 - tape_3590_work_handler(struct work_struct *work) 601 - { 602 - struct work_handler_data *p = 603 - container_of(work, struct work_handler_data, work); 604 - 605 - switch (p->op) { 606 - case TO_MSEN: 607 - tape_3590_sense_medium_async(p->device); 608 - break; 609 - case TO_READ_ATTMSG: 610 - tape_3590_read_attmsg_async(p->device); 611 - break; 612 - case TO_CRYPT_ON: 613 - tape_3592_enable_crypt_async(p->device); 614 - break; 615 - case TO_CRYPT_OFF: 616 - tape_3592_disable_crypt_async(p->device); 617 - break; 618 - default: 619 - DBF_EVENT(3, "T3590: work handler undefined for " 620 - "operation 0x%02x\n", p->op); 621 - } 622 - tape_put_device(p->device); 623 - kfree(p); 624 - } 625 - 626 - static int 627 - tape_3590_schedule_work(struct tape_device *device, enum tape_op op) 628 - { 629 - struct work_handler_data *p; 630 - 631 - if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL) 632 - return -ENOMEM; 633 - 634 - INIT_WORK(&p->work, tape_3590_work_handler); 635 - 636 - p->device = tape_get_device(device); 637 - p->op = op; 638 - 639 - queue_work(tape_3590_wq, &p->work); 640 - return 0; 641 - } 642 - 643 - static void tape_3590_med_state_set(struct tape_device *device, 644 - struct tape_3590_med_sense *sense) 645 - { 646 - struct tape390_crypt_info *c_info; 647 - 648 - c_info = &TAPE_3590_CRYPT_INFO(device); 649 - 650 - DBF_EVENT(6, "medium state: %x:%x\n", sense->macst, sense->masst); 651 - switch (sense->macst) { 652 - case 0x04: 653 - case 0x05: 654 - case 0x06: 655 - tape_med_state_set(device, MS_UNLOADED); 656 - TAPE_3590_CRYPT_INFO(device).medium_status = 0; 657 - return; 658 - case 0x08: 659 - case 0x09: 660 - tape_med_state_set(device, MS_LOADED); 661 - break; 662 - default: 663 - tape_med_state_set(device, MS_UNKNOWN); 664 - return; 665 - } 666 - c_info->medium_status |= TAPE390_MEDIUM_LOADED_MASK; 667 - if (sense->flags & MSENSE_CRYPT_MASK) { 668 - DBF_EVENT(6, "Medium is encrypted (%04x)\n", sense->flags); 669 - c_info->medium_status |= TAPE390_MEDIUM_ENCRYPTED_MASK; 670 - } else { 671 - DBF_EVENT(6, "Medium is not encrypted %04x\n", sense->flags); 672 - c_info->medium_status &= ~TAPE390_MEDIUM_ENCRYPTED_MASK; 673 - } 674 - } 675 - 676 - /* 677 - * The done handler is called at device/channel end and wakes up the sleeping 678 - * process 679 - */ 680 - static int 681 - tape_3590_done(struct tape_device *device, struct tape_request *request) 682 - { 683 - 684 - DBF_EVENT(6, "%s done\n", tape_op_verbose[request->op]); 685 - 686 - switch (request->op) { 687 - case TO_BSB: 688 - case TO_BSF: 689 - case TO_DSE: 690 - case TO_FSB: 691 - case TO_FSF: 692 - case TO_LBL: 693 - case TO_RFO: 694 - case TO_RBA: 695 - case TO_REW: 696 - case TO_WRI: 697 - case TO_WTM: 698 - case TO_BLOCK: 699 - case TO_LOAD: 700 - tape_med_state_set(device, MS_LOADED); 701 - break; 702 - case TO_RUN: 703 - tape_med_state_set(device, MS_UNLOADED); 704 - tape_3590_schedule_work(device, TO_CRYPT_OFF); 705 - break; 706 - case TO_MSEN: 707 - tape_3590_med_state_set(device, request->cpdata); 708 - break; 709 - case TO_CRYPT_ON: 710 - TAPE_3590_CRYPT_INFO(device).status 711 - |= TAPE390_CRYPT_ON_MASK; 712 - *(device->modeset_byte) |= 0x03; 713 - break; 714 - case TO_CRYPT_OFF: 715 - TAPE_3590_CRYPT_INFO(device).status 716 - &= ~TAPE390_CRYPT_ON_MASK; 717 - *(device->modeset_byte) &= ~0x03; 718 - break; 719 - case TO_RBI: /* RBI seems to succeed even without medium loaded. */ 720 - case TO_NOP: /* Same to NOP. */ 721 - case TO_READ_CONFIG: 722 - case TO_READ_ATTMSG: 723 - case TO_DIS: 724 - case TO_ASSIGN: 725 - case TO_UNASSIGN: 726 - case TO_SIZE: 727 - case TO_KEKL_SET: 728 - case TO_KEKL_QUERY: 729 - case TO_RDC: 730 - break; 731 - } 732 - return TAPE_IO_SUCCESS; 733 - } 734 - 735 - /* 736 - * This function is called, when error recovery was successful 737 - */ 738 - static inline int 739 - tape_3590_erp_succeeded(struct tape_device *device, struct tape_request *request) 740 - { 741 - DBF_EVENT(3, "Error Recovery successful for %s\n", 742 - tape_op_verbose[request->op]); 743 - return tape_3590_done(device, request); 744 - } 745 - 746 - /* 747 - * This function is called, when error recovery was not successful 748 - */ 749 - static inline int 750 - tape_3590_erp_failed(struct tape_device *device, struct tape_request *request, 751 - struct irb *irb, int rc) 752 - { 753 - DBF_EVENT(3, "Error Recovery failed for %s\n", 754 - tape_op_verbose[request->op]); 755 - tape_dump_sense_dbf(device, request, irb); 756 - return rc; 757 - } 758 - 759 - /* 760 - * Error Recovery do retry 761 - */ 762 - static inline int 763 - tape_3590_erp_retry(struct tape_device *device, struct tape_request *request, 764 - struct irb *irb) 765 - { 766 - DBF_EVENT(2, "Retry: %s\n", tape_op_verbose[request->op]); 767 - tape_dump_sense_dbf(device, request, irb); 768 - return TAPE_IO_RETRY; 769 - } 770 - 771 - /* 772 - * Handle unsolicited interrupts 773 - */ 774 - static int 775 - tape_3590_unsolicited_irq(struct tape_device *device, struct irb *irb) 776 - { 777 - if (irb->scsw.cmd.dstat == DEV_STAT_CHN_END) 778 - /* Probably result of halt ssch */ 779 - return TAPE_IO_PENDING; 780 - else if (irb->scsw.cmd.dstat == 0x85) 781 - /* Device Ready */ 782 - DBF_EVENT(3, "unsol.irq! tape ready: %08x\n", device->cdev_id); 783 - else if (irb->scsw.cmd.dstat & DEV_STAT_ATTENTION) { 784 - tape_3590_schedule_work(device, TO_READ_ATTMSG); 785 - } else { 786 - DBF_EVENT(3, "unsol.irq! dev end: %08x\n", device->cdev_id); 787 - tape_dump_sense_dbf(device, NULL, irb); 788 - } 789 - /* check medium state */ 790 - tape_3590_schedule_work(device, TO_MSEN); 791 - return TAPE_IO_SUCCESS; 792 - } 793 - 794 - /* 795 - * Basic Recovery routine 796 - */ 797 - static int 798 - tape_3590_erp_basic(struct tape_device *device, struct tape_request *request, 799 - struct irb *irb, int rc) 800 - { 801 - struct tape_3590_sense *sense; 802 - 803 - sense = (struct tape_3590_sense *) irb->ecw; 804 - 805 - switch (sense->bra) { 806 - case SENSE_BRA_PER: 807 - return tape_3590_erp_failed(device, request, irb, rc); 808 - case SENSE_BRA_CONT: 809 - return tape_3590_erp_succeeded(device, request); 810 - case SENSE_BRA_RE: 811 - return tape_3590_erp_retry(device, request, irb); 812 - case SENSE_BRA_DRE: 813 - return tape_3590_erp_failed(device, request, irb, rc); 814 - default: 815 - BUG(); 816 - return TAPE_IO_STOP; 817 - } 818 - } 819 - 820 - /* 821 - * RDL: Read Device (buffered) log 822 - */ 823 - static int 824 - tape_3590_erp_read_buf_log(struct tape_device *device, 825 - struct tape_request *request, struct irb *irb) 826 - { 827 - /* 828 - * We just do the basic error recovery at the moment (retry). 829 - * Perhaps in the future, we read the log and dump it somewhere... 830 - */ 831 - return tape_3590_erp_basic(device, request, irb, -EIO); 832 - } 833 - 834 - /* 835 - * SWAP: Swap Devices 836 - */ 837 - static int 838 - tape_3590_erp_swap(struct tape_device *device, struct tape_request *request, 839 - struct irb *irb) 840 - { 841 - /* 842 - * This error recovery should swap the tapes 843 - * if the original has a problem. The operation 844 - * should proceed with the new tape... this 845 - * should probably be done in user space! 846 - */ 847 - dev_warn (&device->cdev->dev, "The tape medium must be loaded into a " 848 - "different tape unit\n"); 849 - return tape_3590_erp_basic(device, request, irb, -EIO); 850 - } 851 - 852 - /* 853 - * LBY: Long Busy 854 - */ 855 - static int 856 - tape_3590_erp_long_busy(struct tape_device *device, 857 - struct tape_request *request, struct irb *irb) 858 - { 859 - DBF_EVENT(6, "Device is busy\n"); 860 - return TAPE_IO_LONG_BUSY; 861 - } 862 - 863 - /* 864 - * SPI: Special Intercept 865 - */ 866 - static int 867 - tape_3590_erp_special_interrupt(struct tape_device *device, 868 - struct tape_request *request, struct irb *irb) 869 - { 870 - return tape_3590_erp_basic(device, request, irb, -EIO); 871 - } 872 - 873 - /* 874 - * Print an MIM (Media Information Message) (message code f0) 875 - */ 876 - static void 877 - tape_3590_print_mim_msg_f0(struct tape_device *device, struct irb *irb) 878 - { 879 - struct tape_3590_sense *sense; 880 - char *exception, *service; 881 - 882 - exception = kmalloc(BUFSIZE, GFP_ATOMIC); 883 - service = kmalloc(BUFSIZE, GFP_ATOMIC); 884 - 885 - if (!exception || !service) 886 - goto out_nomem; 887 - 888 - sense = (struct tape_3590_sense *) irb->ecw; 889 - /* Exception Message */ 890 - switch (sense->fmt.f70.emc) { 891 - case 0x02: 892 - snprintf(exception, BUFSIZE, "Data degraded"); 893 - break; 894 - case 0x03: 895 - snprintf(exception, BUFSIZE, "Data degraded in partition %i", 896 - sense->fmt.f70.mp); 897 - break; 898 - case 0x04: 899 - snprintf(exception, BUFSIZE, "Medium degraded"); 900 - break; 901 - case 0x05: 902 - snprintf(exception, BUFSIZE, "Medium degraded in partition %i", 903 - sense->fmt.f70.mp); 904 - break; 905 - case 0x06: 906 - snprintf(exception, BUFSIZE, "Block 0 Error"); 907 - break; 908 - case 0x07: 909 - snprintf(exception, BUFSIZE, "Medium Exception 0x%02x", 910 - sense->fmt.f70.md); 911 - break; 912 - default: 913 - snprintf(exception, BUFSIZE, "0x%02x", 914 - sense->fmt.f70.emc); 915 - break; 916 - } 917 - /* Service Message */ 918 - switch (sense->fmt.f70.smc) { 919 - case 0x02: 920 - snprintf(service, BUFSIZE, "Reference Media maintenance " 921 - "procedure %i", sense->fmt.f70.md); 922 - break; 923 - default: 924 - snprintf(service, BUFSIZE, "0x%02x", 925 - sense->fmt.f70.smc); 926 - break; 927 - } 928 - 929 - dev_warn (&device->cdev->dev, "Tape media information: exception %s, " 930 - "service %s\n", exception, service); 931 - 932 - out_nomem: 933 - kfree(exception); 934 - kfree(service); 935 - } 936 - 937 - /* 938 - * Print an I/O Subsystem Service Information Message (message code f1) 939 - */ 940 - static void 941 - tape_3590_print_io_sim_msg_f1(struct tape_device *device, struct irb *irb) 942 - { 943 - struct tape_3590_sense *sense; 944 - char *exception, *service; 945 - 946 - exception = kmalloc(BUFSIZE, GFP_ATOMIC); 947 - service = kmalloc(BUFSIZE, GFP_ATOMIC); 948 - 949 - if (!exception || !service) 950 - goto out_nomem; 951 - 952 - sense = (struct tape_3590_sense *) irb->ecw; 953 - /* Exception Message */ 954 - switch (sense->fmt.f71.emc) { 955 - case 0x01: 956 - snprintf(exception, BUFSIZE, "Effect of failure is unknown"); 957 - break; 958 - case 0x02: 959 - snprintf(exception, BUFSIZE, "CU Exception - no performance " 960 - "impact"); 961 - break; 962 - case 0x03: 963 - snprintf(exception, BUFSIZE, "CU Exception on channel " 964 - "interface 0x%02x", sense->fmt.f71.md[0]); 965 - break; 966 - case 0x04: 967 - snprintf(exception, BUFSIZE, "CU Exception on device path " 968 - "0x%02x", sense->fmt.f71.md[0]); 969 - break; 970 - case 0x05: 971 - snprintf(exception, BUFSIZE, "CU Exception on library path " 972 - "0x%02x", sense->fmt.f71.md[0]); 973 - break; 974 - case 0x06: 975 - snprintf(exception, BUFSIZE, "CU Exception on node 0x%02x", 976 - sense->fmt.f71.md[0]); 977 - break; 978 - case 0x07: 979 - snprintf(exception, BUFSIZE, "CU Exception on partition " 980 - "0x%02x", sense->fmt.f71.md[0]); 981 - break; 982 - default: 983 - snprintf(exception, BUFSIZE, "0x%02x", 984 - sense->fmt.f71.emc); 985 - } 986 - /* Service Message */ 987 - switch (sense->fmt.f71.smc) { 988 - case 0x01: 989 - snprintf(service, BUFSIZE, "Repair impact is unknown"); 990 - break; 991 - case 0x02: 992 - snprintf(service, BUFSIZE, "Repair will not impact cu " 993 - "performance"); 994 - break; 995 - case 0x03: 996 - if (sense->fmt.f71.mdf == 0) 997 - snprintf(service, BUFSIZE, "Repair will disable node " 998 - "0x%x on CU", sense->fmt.f71.md[1]); 999 - else 1000 - snprintf(service, BUFSIZE, "Repair will disable " 1001 - "nodes (0x%x-0x%x) on CU", sense->fmt.f71.md[1], 1002 - sense->fmt.f71.md[2]); 1003 - break; 1004 - case 0x04: 1005 - if (sense->fmt.f71.mdf == 0) 1006 - snprintf(service, BUFSIZE, "Repair will disable " 1007 - "channel path 0x%x on CU", 1008 - sense->fmt.f71.md[1]); 1009 - else 1010 - snprintf(service, BUFSIZE, "Repair will disable channel" 1011 - " paths (0x%x-0x%x) on CU", 1012 - sense->fmt.f71.md[1], sense->fmt.f71.md[2]); 1013 - break; 1014 - case 0x05: 1015 - if (sense->fmt.f71.mdf == 0) 1016 - snprintf(service, BUFSIZE, "Repair will disable device" 1017 - " path 0x%x on CU", sense->fmt.f71.md[1]); 1018 - else 1019 - snprintf(service, BUFSIZE, "Repair will disable device" 1020 - " paths (0x%x-0x%x) on CU", 1021 - sense->fmt.f71.md[1], sense->fmt.f71.md[2]); 1022 - break; 1023 - case 0x06: 1024 - if (sense->fmt.f71.mdf == 0) 1025 - snprintf(service, BUFSIZE, "Repair will disable " 1026 - "library path 0x%x on CU", 1027 - sense->fmt.f71.md[1]); 1028 - else 1029 - snprintf(service, BUFSIZE, "Repair will disable " 1030 - "library paths (0x%x-0x%x) on CU", 1031 - sense->fmt.f71.md[1], sense->fmt.f71.md[2]); 1032 - break; 1033 - case 0x07: 1034 - snprintf(service, BUFSIZE, "Repair will disable access to CU"); 1035 - break; 1036 - default: 1037 - snprintf(service, BUFSIZE, "0x%02x", 1038 - sense->fmt.f71.smc); 1039 - } 1040 - 1041 - dev_warn (&device->cdev->dev, "I/O subsystem information: exception" 1042 - " %s, service %s\n", exception, service); 1043 - out_nomem: 1044 - kfree(exception); 1045 - kfree(service); 1046 - } 1047 - 1048 - /* 1049 - * Print an Device Subsystem Service Information Message (message code f2) 1050 - */ 1051 - static void 1052 - tape_3590_print_dev_sim_msg_f2(struct tape_device *device, struct irb *irb) 1053 - { 1054 - struct tape_3590_sense *sense; 1055 - char *exception, *service; 1056 - 1057 - exception = kmalloc(BUFSIZE, GFP_ATOMIC); 1058 - service = kmalloc(BUFSIZE, GFP_ATOMIC); 1059 - 1060 - if (!exception || !service) 1061 - goto out_nomem; 1062 - 1063 - sense = (struct tape_3590_sense *) irb->ecw; 1064 - /* Exception Message */ 1065 - switch (sense->fmt.f71.emc) { 1066 - case 0x01: 1067 - snprintf(exception, BUFSIZE, "Effect of failure is unknown"); 1068 - break; 1069 - case 0x02: 1070 - snprintf(exception, BUFSIZE, "DV Exception - no performance" 1071 - " impact"); 1072 - break; 1073 - case 0x03: 1074 - snprintf(exception, BUFSIZE, "DV Exception on channel " 1075 - "interface 0x%02x", sense->fmt.f71.md[0]); 1076 - break; 1077 - case 0x04: 1078 - snprintf(exception, BUFSIZE, "DV Exception on loader 0x%02x", 1079 - sense->fmt.f71.md[0]); 1080 - break; 1081 - case 0x05: 1082 - snprintf(exception, BUFSIZE, "DV Exception on message display" 1083 - " 0x%02x", sense->fmt.f71.md[0]); 1084 - break; 1085 - case 0x06: 1086 - snprintf(exception, BUFSIZE, "DV Exception in tape path"); 1087 - break; 1088 - case 0x07: 1089 - snprintf(exception, BUFSIZE, "DV Exception in drive"); 1090 - break; 1091 - default: 1092 - snprintf(exception, BUFSIZE, "0x%02x", 1093 - sense->fmt.f71.emc); 1094 - } 1095 - /* Service Message */ 1096 - switch (sense->fmt.f71.smc) { 1097 - case 0x01: 1098 - snprintf(service, BUFSIZE, "Repair impact is unknown"); 1099 - break; 1100 - case 0x02: 1101 - snprintf(service, BUFSIZE, "Repair will not impact device " 1102 - "performance"); 1103 - break; 1104 - case 0x03: 1105 - if (sense->fmt.f71.mdf == 0) 1106 - snprintf(service, BUFSIZE, "Repair will disable " 1107 - "channel path 0x%x on DV", 1108 - sense->fmt.f71.md[1]); 1109 - else 1110 - snprintf(service, BUFSIZE, "Repair will disable " 1111 - "channel path (0x%x-0x%x) on DV", 1112 - sense->fmt.f71.md[1], sense->fmt.f71.md[2]); 1113 - break; 1114 - case 0x04: 1115 - if (sense->fmt.f71.mdf == 0) 1116 - snprintf(service, BUFSIZE, "Repair will disable " 1117 - "interface 0x%x on DV", sense->fmt.f71.md[1]); 1118 - else 1119 - snprintf(service, BUFSIZE, "Repair will disable " 1120 - "interfaces (0x%x-0x%x) on DV", 1121 - sense->fmt.f71.md[1], sense->fmt.f71.md[2]); 1122 - break; 1123 - case 0x05: 1124 - if (sense->fmt.f71.mdf == 0) 1125 - snprintf(service, BUFSIZE, "Repair will disable loader" 1126 - " 0x%x on DV", sense->fmt.f71.md[1]); 1127 - else 1128 - snprintf(service, BUFSIZE, "Repair will disable loader" 1129 - " (0x%x-0x%x) on DV", 1130 - sense->fmt.f71.md[1], sense->fmt.f71.md[2]); 1131 - break; 1132 - case 0x07: 1133 - snprintf(service, BUFSIZE, "Repair will disable access to DV"); 1134 - break; 1135 - case 0x08: 1136 - if (sense->fmt.f71.mdf == 0) 1137 - snprintf(service, BUFSIZE, "Repair will disable " 1138 - "message display 0x%x on DV", 1139 - sense->fmt.f71.md[1]); 1140 - else 1141 - snprintf(service, BUFSIZE, "Repair will disable " 1142 - "message displays (0x%x-0x%x) on DV", 1143 - sense->fmt.f71.md[1], sense->fmt.f71.md[2]); 1144 - break; 1145 - case 0x09: 1146 - snprintf(service, BUFSIZE, "Clean DV"); 1147 - break; 1148 - default: 1149 - snprintf(service, BUFSIZE, "0x%02x", 1150 - sense->fmt.f71.smc); 1151 - } 1152 - 1153 - dev_warn (&device->cdev->dev, "Device subsystem information: exception" 1154 - " %s, service %s\n", exception, service); 1155 - out_nomem: 1156 - kfree(exception); 1157 - kfree(service); 1158 - } 1159 - 1160 - /* 1161 - * Print standard ERA Message 1162 - */ 1163 - static void 1164 - tape_3590_print_era_msg(struct tape_device *device, struct irb *irb) 1165 - { 1166 - struct tape_3590_sense *sense; 1167 - 1168 - sense = (struct tape_3590_sense *) irb->ecw; 1169 - if (sense->mc == 0) 1170 - return; 1171 - if ((sense->mc > 0) && (sense->mc < TAPE_3590_MAX_MSG)) { 1172 - if (tape_3590_msg[sense->mc] != NULL) 1173 - dev_warn (&device->cdev->dev, "The tape unit has " 1174 - "issued sense message %s\n", 1175 - tape_3590_msg[sense->mc]); 1176 - else 1177 - dev_warn (&device->cdev->dev, "The tape unit has " 1178 - "issued an unknown sense message code 0x%x\n", 1179 - sense->mc); 1180 - return; 1181 - } 1182 - if (sense->mc == 0xf0) { 1183 - /* Standard Media Information Message */ 1184 - dev_warn (&device->cdev->dev, "MIM SEV=%i, MC=%02x, ES=%x/%x, " 1185 - "RC=%02x-%04x-%02x\n", sense->fmt.f70.sev, sense->mc, 1186 - sense->fmt.f70.emc, sense->fmt.f70.smc, 1187 - sense->fmt.f70.refcode, sense->fmt.f70.mid, 1188 - sense->fmt.f70.fid); 1189 - tape_3590_print_mim_msg_f0(device, irb); 1190 - return; 1191 - } 1192 - if (sense->mc == 0xf1) { 1193 - /* Standard I/O Subsystem Service Information Message */ 1194 - dev_warn (&device->cdev->dev, "IOSIM SEV=%i, DEVTYPE=3590/%02x," 1195 - " MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n", 1196 - sense->fmt.f71.sev, device->cdev->id.dev_model, 1197 - sense->mc, sense->fmt.f71.emc, sense->fmt.f71.smc, 1198 - sense->fmt.f71.refcode1, sense->fmt.f71.refcode2, 1199 - sense->fmt.f71.refcode3); 1200 - tape_3590_print_io_sim_msg_f1(device, irb); 1201 - return; 1202 - } 1203 - if (sense->mc == 0xf2) { 1204 - /* Standard Device Service Information Message */ 1205 - dev_warn (&device->cdev->dev, "DEVSIM SEV=%i, DEVTYPE=3590/%02x" 1206 - ", MC=%02x, ES=%x/%x, REF=0x%04x-0x%04x-0x%04x\n", 1207 - sense->fmt.f71.sev, device->cdev->id.dev_model, 1208 - sense->mc, sense->fmt.f71.emc, sense->fmt.f71.smc, 1209 - sense->fmt.f71.refcode1, sense->fmt.f71.refcode2, 1210 - sense->fmt.f71.refcode3); 1211 - tape_3590_print_dev_sim_msg_f2(device, irb); 1212 - return; 1213 - } 1214 - if (sense->mc == 0xf3) { 1215 - /* Standard Library Service Information Message */ 1216 - return; 1217 - } 1218 - dev_warn (&device->cdev->dev, "The tape unit has issued an unknown " 1219 - "sense message code %x\n", sense->mc); 1220 - } 1221 - 1222 - static int tape_3590_crypt_error(struct tape_device *device, 1223 - struct tape_request *request, struct irb *irb) 1224 - { 1225 - u8 cu_rc; 1226 - u16 ekm_rc2; 1227 - char *sense; 1228 - 1229 - sense = ((struct tape_3590_sense *) irb->ecw)->fmt.data; 1230 - cu_rc = sense[0]; 1231 - ekm_rc2 = *((u16*) &sense[10]); 1232 - if ((cu_rc == 0) && (ekm_rc2 == 0xee31)) 1233 - /* key not defined on EKM */ 1234 - return tape_3590_erp_basic(device, request, irb, -EKEYREJECTED); 1235 - if ((cu_rc == 1) || (cu_rc == 2)) 1236 - /* No connection to EKM */ 1237 - return tape_3590_erp_basic(device, request, irb, -ENOTCONN); 1238 - 1239 - dev_err (&device->cdev->dev, "The tape unit failed to obtain the " 1240 - "encryption key from EKM\n"); 1241 - 1242 - return tape_3590_erp_basic(device, request, irb, -ENOKEY); 1243 - } 1244 - 1245 - /* 1246 - * 3590 error Recovery routine: 1247 - * If possible, it tries to recover from the error. If this is not possible, 1248 - * inform the user about the problem. 1249 - */ 1250 - static int 1251 - tape_3590_unit_check(struct tape_device *device, struct tape_request *request, 1252 - struct irb *irb) 1253 - { 1254 - struct tape_3590_sense *sense; 1255 - 1256 - sense = (struct tape_3590_sense *) irb->ecw; 1257 - 1258 - DBF_EVENT(6, "Unit Check: RQC = %x\n", sense->rc_rqc); 1259 - 1260 - /* 1261 - * First check all RC-QRCs where we want to do something special 1262 - * - "break": basic error recovery is done 1263 - * - "goto out:": just print error message if available 1264 - */ 1265 - switch (sense->rc_rqc) { 1266 - 1267 - case 0x1110: 1268 - tape_3590_print_era_msg(device, irb); 1269 - return tape_3590_erp_read_buf_log(device, request, irb); 1270 - 1271 - case 0x2230: 1272 - case 0x2231: 1273 - tape_3590_print_era_msg(device, irb); 1274 - return tape_3590_erp_special_interrupt(device, request, irb); 1275 - case 0x2240: 1276 - return tape_3590_crypt_error(device, request, irb); 1277 - 1278 - case 0x3010: 1279 - DBF_EVENT(2, "(%08x): Backward at Beginning of Partition\n", 1280 - device->cdev_id); 1281 - return tape_3590_erp_basic(device, request, irb, -ENOSPC); 1282 - case 0x3012: 1283 - DBF_EVENT(2, "(%08x): Forward at End of Partition\n", 1284 - device->cdev_id); 1285 - return tape_3590_erp_basic(device, request, irb, -ENOSPC); 1286 - case 0x3020: 1287 - DBF_EVENT(2, "(%08x): End of Data Mark\n", device->cdev_id); 1288 - return tape_3590_erp_basic(device, request, irb, -ENOSPC); 1289 - 1290 - case 0x3122: 1291 - DBF_EVENT(2, "(%08x): Rewind Unload initiated\n", 1292 - device->cdev_id); 1293 - return tape_3590_erp_basic(device, request, irb, -EIO); 1294 - case 0x3123: 1295 - DBF_EVENT(2, "(%08x): Rewind Unload complete\n", 1296 - device->cdev_id); 1297 - tape_med_state_set(device, MS_UNLOADED); 1298 - tape_3590_schedule_work(device, TO_CRYPT_OFF); 1299 - return tape_3590_erp_basic(device, request, irb, 0); 1300 - 1301 - case 0x4010: 1302 - /* 1303 - * print additional msg since default msg 1304 - * "device intervention" is not very meaningfull 1305 - */ 1306 - tape_med_state_set(device, MS_UNLOADED); 1307 - tape_3590_schedule_work(device, TO_CRYPT_OFF); 1308 - return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM); 1309 - case 0x4012: /* Device Long Busy */ 1310 - /* XXX: Also use long busy handling here? */ 1311 - DBF_EVENT(6, "(%08x): LONG BUSY\n", device->cdev_id); 1312 - tape_3590_print_era_msg(device, irb); 1313 - return tape_3590_erp_basic(device, request, irb, -EBUSY); 1314 - case 0x4014: 1315 - DBF_EVENT(6, "(%08x): Crypto LONG BUSY\n", device->cdev_id); 1316 - return tape_3590_erp_long_busy(device, request, irb); 1317 - 1318 - case 0x5010: 1319 - if (sense->rac == 0xd0) { 1320 - /* Swap */ 1321 - tape_3590_print_era_msg(device, irb); 1322 - return tape_3590_erp_swap(device, request, irb); 1323 - } 1324 - return tape_3590_erp_basic(device, request, irb, -EIO); 1325 - case 0x5020: 1326 - case 0x5021: 1327 - case 0x5022: 1328 - case 0x5040: 1329 - case 0x5041: 1330 - case 0x5042: 1331 - tape_3590_print_era_msg(device, irb); 1332 - return tape_3590_erp_swap(device, request, irb); 1333 - 1334 - case 0x5110: 1335 - case 0x5111: 1336 - return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE); 1337 - 1338 - case 0x5120: 1339 - case 0x1120: 1340 - tape_med_state_set(device, MS_UNLOADED); 1341 - tape_3590_schedule_work(device, TO_CRYPT_OFF); 1342 - return tape_3590_erp_basic(device, request, irb, -ENOMEDIUM); 1343 - 1344 - case 0x6020: 1345 - return tape_3590_erp_basic(device, request, irb, -EMEDIUMTYPE); 1346 - 1347 - case 0x8011: 1348 - return tape_3590_erp_basic(device, request, irb, -EPERM); 1349 - case 0x8013: 1350 - dev_warn (&device->cdev->dev, "A different host has privileged" 1351 - " access to the tape unit\n"); 1352 - return tape_3590_erp_basic(device, request, irb, -EPERM); 1353 - default: 1354 - return tape_3590_erp_basic(device, request, irb, -EIO); 1355 - } 1356 - } 1357 - 1358 - /* 1359 - * 3590 interrupt handler: 1360 - */ 1361 - static int 1362 - tape_3590_irq(struct tape_device *device, struct tape_request *request, 1363 - struct irb *irb) 1364 - { 1365 - if (request == NULL) 1366 - return tape_3590_unsolicited_irq(device, irb); 1367 - 1368 - if ((irb->scsw.cmd.dstat & DEV_STAT_UNIT_EXCEP) && 1369 - (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) && 1370 - (request->op == TO_WRI)) { 1371 - /* Write at end of volume */ 1372 - DBF_EVENT(2, "End of volume\n"); 1373 - return tape_3590_erp_failed(device, request, irb, -ENOSPC); 1374 - } 1375 - 1376 - if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) 1377 - return tape_3590_unit_check(device, request, irb); 1378 - 1379 - if (irb->scsw.cmd.dstat & DEV_STAT_DEV_END) { 1380 - if (irb->scsw.cmd.dstat == DEV_STAT_UNIT_EXCEP) { 1381 - if (request->op == TO_FSB || request->op == TO_BSB) 1382 - request->rescnt++; 1383 - else 1384 - DBF_EVENT(5, "Unit Exception!\n"); 1385 - } 1386 - 1387 - return tape_3590_done(device, request); 1388 - } 1389 - 1390 - if (irb->scsw.cmd.dstat & DEV_STAT_CHN_END) { 1391 - DBF_EVENT(2, "channel end\n"); 1392 - return TAPE_IO_PENDING; 1393 - } 1394 - 1395 - if (irb->scsw.cmd.dstat & DEV_STAT_ATTENTION) { 1396 - DBF_EVENT(2, "Unit Attention when busy..\n"); 1397 - return TAPE_IO_PENDING; 1398 - } 1399 - 1400 - DBF_EVENT(6, "xunknownirq\n"); 1401 - tape_dump_sense_dbf(device, request, irb); 1402 - return TAPE_IO_STOP; 1403 - } 1404 - 1405 - 1406 - static int tape_3590_read_dev_chars(struct tape_device *device, 1407 - struct tape_3590_rdc_data *rdc_data) 1408 - { 1409 - int rc; 1410 - struct tape_request *request; 1411 - 1412 - request = tape_alloc_request(1, sizeof(*rdc_data)); 1413 - if (IS_ERR(request)) 1414 - return PTR_ERR(request); 1415 - request->op = TO_RDC; 1416 - tape_ccw_end(request->cpaddr, CCW_CMD_RDC, sizeof(*rdc_data), 1417 - request->cpdata); 1418 - rc = tape_do_io(device, request); 1419 - if (rc == 0) 1420 - memcpy(rdc_data, request->cpdata, sizeof(*rdc_data)); 1421 - tape_free_request(request); 1422 - return rc; 1423 - } 1424 - 1425 - /* 1426 - * Setup device function 1427 - */ 1428 - static int 1429 - tape_3590_setup_device(struct tape_device *device) 1430 - { 1431 - int rc; 1432 - struct tape_3590_disc_data *data; 1433 - struct tape_3590_rdc_data *rdc_data; 1434 - 1435 - DBF_EVENT(6, "3590 device setup\n"); 1436 - data = kzalloc(sizeof(struct tape_3590_disc_data), GFP_KERNEL | GFP_DMA); 1437 - if (data == NULL) 1438 - return -ENOMEM; 1439 - data->read_back_op = READ_PREVIOUS; 1440 - device->discdata = data; 1441 - 1442 - rdc_data = kmalloc(sizeof(*rdc_data), GFP_KERNEL | GFP_DMA); 1443 - if (!rdc_data) { 1444 - rc = -ENOMEM; 1445 - goto fail_kmalloc; 1446 - } 1447 - rc = tape_3590_read_dev_chars(device, rdc_data); 1448 - if (rc) { 1449 - DBF_LH(3, "Read device characteristics failed!\n"); 1450 - goto fail_rdc_data; 1451 - } 1452 - rc = tape_std_assign(device); 1453 - if (rc) 1454 - goto fail_rdc_data; 1455 - if (rdc_data->data[31] == 0x13) { 1456 - data->crypt_info.capability |= TAPE390_CRYPT_SUPPORTED_MASK; 1457 - tape_3592_disable_crypt(device); 1458 - } else { 1459 - DBF_EVENT(6, "Device has NO crypto support\n"); 1460 - } 1461 - /* Try to find out if medium is loaded */ 1462 - rc = tape_3590_sense_medium(device); 1463 - if (rc) { 1464 - DBF_LH(3, "3590 medium sense returned %d\n", rc); 1465 - goto fail_rdc_data; 1466 - } 1467 - return 0; 1468 - 1469 - fail_rdc_data: 1470 - kfree(rdc_data); 1471 - fail_kmalloc: 1472 - kfree(data); 1473 - return rc; 1474 - } 1475 - 1476 - /* 1477 - * Cleanup device function 1478 - */ 1479 - static void 1480 - tape_3590_cleanup_device(struct tape_device *device) 1481 - { 1482 - flush_workqueue(tape_3590_wq); 1483 - tape_std_unassign(device); 1484 - 1485 - kfree(device->discdata); 1486 - device->discdata = NULL; 1487 - } 1488 - 1489 - /* 1490 - * List of 3590 magnetic tape commands. 1491 - */ 1492 - static tape_mtop_fn tape_3590_mtop[TAPE_NR_MTOPS] = { 1493 - [MTRESET] = tape_std_mtreset, 1494 - [MTFSF] = tape_std_mtfsf, 1495 - [MTBSF] = tape_std_mtbsf, 1496 - [MTFSR] = tape_std_mtfsr, 1497 - [MTBSR] = tape_std_mtbsr, 1498 - [MTWEOF] = tape_std_mtweof, 1499 - [MTREW] = tape_std_mtrew, 1500 - [MTOFFL] = tape_std_mtoffl, 1501 - [MTNOP] = tape_std_mtnop, 1502 - [MTRETEN] = tape_std_mtreten, 1503 - [MTBSFM] = tape_std_mtbsfm, 1504 - [MTFSFM] = tape_std_mtfsfm, 1505 - [MTEOM] = tape_std_mteom, 1506 - [MTERASE] = tape_std_mterase, 1507 - [MTRAS1] = NULL, 1508 - [MTRAS2] = NULL, 1509 - [MTRAS3] = NULL, 1510 - [MTSETBLK] = tape_std_mtsetblk, 1511 - [MTSETDENSITY] = NULL, 1512 - [MTSEEK] = tape_3590_mtseek, 1513 - [MTTELL] = tape_3590_mttell, 1514 - [MTSETDRVBUFFER] = NULL, 1515 - [MTFSS] = NULL, 1516 - [MTBSS] = NULL, 1517 - [MTWSM] = NULL, 1518 - [MTLOCK] = NULL, 1519 - [MTUNLOCK] = NULL, 1520 - [MTLOAD] = tape_std_mtload, 1521 - [MTUNLOAD] = tape_std_mtunload, 1522 - [MTCOMPRESSION] = tape_std_mtcompression, 1523 - [MTSETPART] = NULL, 1524 - [MTMKPART] = NULL 1525 - }; 1526 - 1527 - /* 1528 - * Tape discipline structure for 3590. 1529 - */ 1530 - static struct tape_discipline tape_discipline_3590 = { 1531 - .owner = THIS_MODULE, 1532 - .setup_device = tape_3590_setup_device, 1533 - .cleanup_device = tape_3590_cleanup_device, 1534 - .process_eov = tape_std_process_eov, 1535 - .irq = tape_3590_irq, 1536 - .read_block = tape_std_read_block, 1537 - .write_block = tape_std_write_block, 1538 - .ioctl_fn = tape_3590_ioctl, 1539 - .mtop_array = tape_3590_mtop 1540 - }; 1541 - 1542 - static struct ccw_device_id tape_3590_ids[] = { 1543 - {CCW_DEVICE_DEVTYPE(0x3590, 0, 0x3590, 0), .driver_info = tape_3590}, 1544 - {CCW_DEVICE_DEVTYPE(0x3592, 0, 0x3592, 0), .driver_info = tape_3592}, 1545 - { /* end of list */ } 1546 - }; 1547 - 1548 - static int 1549 - tape_3590_online(struct ccw_device *cdev) 1550 - { 1551 - return tape_generic_online(dev_get_drvdata(&cdev->dev), 1552 - &tape_discipline_3590); 1553 - } 1554 - 1555 - static struct ccw_driver tape_3590_driver = { 1556 - .driver = { 1557 - .name = "tape_3590", 1558 - .owner = THIS_MODULE, 1559 - }, 1560 - .ids = tape_3590_ids, 1561 - .probe = tape_generic_probe, 1562 - .remove = tape_generic_remove, 1563 - .set_offline = tape_generic_offline, 1564 - .set_online = tape_3590_online, 1565 - .int_class = IRQIO_TAP, 1566 - }; 1567 - 1568 - /* 1569 - * Setup discipline structure. 1570 - */ 1571 - static int 1572 - tape_3590_init(void) 1573 - { 1574 - int rc; 1575 - 1576 - TAPE_DBF_AREA = debug_register("tape_3590", 2, 2, 4 * sizeof(long)); 1577 - debug_register_view(TAPE_DBF_AREA, &debug_sprintf_view); 1578 - #ifdef DBF_LIKE_HELL 1579 - debug_set_level(TAPE_DBF_AREA, 6); 1580 - #endif 1581 - 1582 - DBF_EVENT(3, "3590 init\n"); 1583 - 1584 - tape_3590_wq = alloc_workqueue("tape_3590", WQ_PERCPU, 0); 1585 - if (!tape_3590_wq) 1586 - return -ENOMEM; 1587 - 1588 - /* Register driver for 3590 tapes. */ 1589 - rc = ccw_driver_register(&tape_3590_driver); 1590 - if (rc) { 1591 - destroy_workqueue(tape_3590_wq); 1592 - DBF_EVENT(3, "3590 init failed\n"); 1593 - } else 1594 - DBF_EVENT(3, "3590 registered\n"); 1595 - return rc; 1596 - } 1597 - 1598 - static void 1599 - tape_3590_exit(void) 1600 - { 1601 - ccw_driver_unregister(&tape_3590_driver); 1602 - destroy_workqueue(tape_3590_wq); 1603 - debug_unregister(TAPE_DBF_AREA); 1604 - } 1605 - 1606 - MODULE_DEVICE_TABLE(ccw, tape_3590_ids); 1607 - MODULE_AUTHOR("(C) 2001,2006 IBM Corporation"); 1608 - MODULE_DESCRIPTION("Linux on zSeries channel attached 3590 tape device driver"); 1609 - MODULE_LICENSE("GPL"); 1610 - 1611 - module_init(tape_3590_init); 1612 - module_exit(tape_3590_exit);
-175
drivers/s390/char/tape_3590.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * tape device discipline for 3590 tapes. 4 - * 5 - * Copyright IBM Corp. 2001, 2006 6 - * Author(s): Stefan Bader <shbader@de.ibm.com> 7 - * Michael Holzheu <holzheu@de.ibm.com> 8 - * Martin Schwidefsky <schwidefsky@de.ibm.com> 9 - */ 10 - 11 - #ifndef _TAPE_3590_H 12 - #define _TAPE_3590_H 13 - 14 - #define MEDIUM_SENSE 0xc2 15 - #define READ_PREVIOUS 0x0a 16 - #define MODE_SENSE 0xcf 17 - #define PERFORM_SS_FUNC 0x77 18 - #define READ_SS_DATA 0x3e 19 - 20 - #define PREP_RD_SS_DATA 0x18 21 - #define RD_ATTMSG 0x3 22 - 23 - #define SENSE_BRA_PER 0 24 - #define SENSE_BRA_CONT 1 25 - #define SENSE_BRA_RE 2 26 - #define SENSE_BRA_DRE 3 27 - 28 - #define SENSE_FMT_LIBRARY 0x23 29 - #define SENSE_FMT_UNSOLICITED 0x40 30 - #define SENSE_FMT_COMMAND_REJ 0x41 31 - #define SENSE_FMT_COMMAND_EXEC0 0x50 32 - #define SENSE_FMT_COMMAND_EXEC1 0x51 33 - #define SENSE_FMT_EVENT0 0x60 34 - #define SENSE_FMT_EVENT1 0x61 35 - #define SENSE_FMT_MIM 0x70 36 - #define SENSE_FMT_SIM 0x71 37 - 38 - #define MSENSE_UNASSOCIATED 0x00 39 - #define MSENSE_ASSOCIATED_MOUNT 0x01 40 - #define MSENSE_ASSOCIATED_UMOUNT 0x02 41 - #define MSENSE_CRYPT_MASK 0x00000010 42 - 43 - #define TAPE_3590_MAX_MSG 0xb0 44 - 45 - /* Datatypes */ 46 - 47 - struct tape_3590_disc_data { 48 - struct tape390_crypt_info crypt_info; 49 - int read_back_op; 50 - }; 51 - 52 - #define TAPE_3590_CRYPT_INFO(device) \ 53 - ((struct tape_3590_disc_data*)(device->discdata))->crypt_info 54 - #define TAPE_3590_READ_BACK_OP(device) \ 55 - ((struct tape_3590_disc_data*)(device->discdata))->read_back_op 56 - 57 - struct tape_3590_sense { 58 - 59 - unsigned int command_rej:1; 60 - unsigned int interv_req:1; 61 - unsigned int bus_out_check:1; 62 - unsigned int eq_check:1; 63 - unsigned int data_check:1; 64 - unsigned int overrun:1; 65 - unsigned int def_unit_check:1; 66 - unsigned int assgnd_elsew:1; 67 - 68 - unsigned int locate_fail:1; 69 - unsigned int inst_online:1; 70 - unsigned int reserved:1; 71 - unsigned int blk_seq_err:1; 72 - unsigned int begin_part:1; 73 - unsigned int wr_mode:1; 74 - unsigned int wr_prot:1; 75 - unsigned int not_cap:1; 76 - 77 - unsigned int bra:2; 78 - unsigned int lc:3; 79 - unsigned int vlf_active:1; 80 - unsigned int stm:1; 81 - unsigned int med_pos:1; 82 - 83 - unsigned int rac:8; 84 - 85 - unsigned int rc_rqc:16; 86 - 87 - unsigned int mc:8; 88 - 89 - unsigned int sense_fmt:8; 90 - 91 - union { 92 - struct { 93 - unsigned int emc:4; 94 - unsigned int smc:4; 95 - unsigned int sev:2; 96 - unsigned int reserved:6; 97 - unsigned int md:8; 98 - unsigned int refcode:8; 99 - unsigned int mid:16; 100 - unsigned int mp:16; 101 - unsigned char volid[6]; 102 - unsigned int fid:8; 103 - } f70; 104 - struct { 105 - unsigned int emc:4; 106 - unsigned int smc:4; 107 - unsigned int sev:2; 108 - unsigned int reserved1:5; 109 - unsigned int mdf:1; 110 - unsigned char md[3]; 111 - unsigned int simid:8; 112 - unsigned int uid:16; 113 - unsigned int refcode1:16; 114 - unsigned int refcode2:16; 115 - unsigned int refcode3:16; 116 - unsigned int reserved2:8; 117 - } f71; 118 - unsigned char data[14]; 119 - } fmt; 120 - unsigned char pad[10]; 121 - 122 - } __attribute__ ((packed)); 123 - 124 - struct tape_3590_med_sense { 125 - unsigned int macst:4; 126 - unsigned int masst:4; 127 - char pad1[7]; 128 - unsigned int flags; 129 - char pad2[116]; 130 - } __attribute__ ((packed)); 131 - 132 - struct tape_3590_rdc_data { 133 - char data[64]; 134 - } __attribute__ ((packed)); 135 - 136 - /* Datastructures for 3592 encryption support */ 137 - 138 - struct tape3592_kekl { 139 - __u8 flags; 140 - char label[64]; 141 - } __attribute__ ((packed)); 142 - 143 - struct tape3592_kekl_pair { 144 - __u8 count; 145 - struct tape3592_kekl kekl[2]; 146 - } __attribute__ ((packed)); 147 - 148 - struct tape3592_kekl_query_data { 149 - __u16 len; 150 - __u8 fmt; 151 - __u8 mc; 152 - __u32 id; 153 - __u8 flags; 154 - struct tape3592_kekl_pair kekls; 155 - char reserved[116]; 156 - } __attribute__ ((packed)); 157 - 158 - struct tape3592_kekl_query_order { 159 - __u8 code; 160 - __u8 flags; 161 - char reserved1[2]; 162 - __u8 max_count; 163 - char reserved2[35]; 164 - } __attribute__ ((packed)); 165 - 166 - struct tape3592_kekl_set_order { 167 - __u8 code; 168 - __u8 flags; 169 - char reserved1[2]; 170 - __u8 op; 171 - struct tape3592_kekl_pair kekls; 172 - char reserved2[120]; 173 - } __attribute__ ((packed)); 174 - 175 - #endif /* _TAPE_3590_H */
+1 -4
drivers/s390/char/tape_char.c
··· 412 412 413 413 return put_user_mtget(data, &get); 414 414 } 415 - /* Try the discipline ioctl function. */ 416 - if (device->discipline->ioctl_fn == NULL) 417 - return -EINVAL; 418 - return device->discipline->ioctl_fn(device, no, (unsigned long)data); 415 + return -EINVAL; 419 416 } 420 417 421 418 static long
+2 -13
drivers/s390/char/tape_class.c
··· 15 15 16 16 #include "tape_class.h" 17 17 18 - MODULE_AUTHOR("Stefan Bader <shbader@de.ibm.com>"); 19 - MODULE_DESCRIPTION( 20 - "Copyright IBM Corp. 2004 All Rights Reserved.\n" 21 - "tape_class.c" 22 - ); 23 - MODULE_LICENSE("GPL"); 24 - 25 18 static const struct class tape_class = { 26 19 .name = "tape390", 27 20 }; ··· 109 116 } 110 117 EXPORT_SYMBOL(unregister_tape_dev); 111 118 112 - 113 - static int __init tape_init(void) 119 + int tape_class_init(void) 114 120 { 115 121 return class_register(&tape_class); 116 122 } 117 123 118 - static void __exit tape_exit(void) 124 + void tape_class_exit(void) 119 125 { 120 126 class_unregister(&tape_class); 121 127 } 122 - 123 - postcore_initcall(tape_init); 124 - module_exit(tape_exit);
+2
drivers/s390/char/tape_class.h
··· 55 55 char * node_name 56 56 ); 57 57 void unregister_tape_dev(struct device *device, struct tape_class_device *tcd); 58 + int tape_class_init(void); 59 + void tape_class_exit(void); 58 60 59 61 #endif /* __TAPE_CLASS_H__ */
+8 -6
drivers/s390/char/tape_core.c
··· 28 28 29 29 #include "tape.h" 30 30 #include "tape_std.h" 31 + #include "tape_class.h" 31 32 32 33 #define LONG_BUSY_TIMEOUT 180 /* seconds */ 33 34 ··· 75 74 [TO_LOAD] = "LOA", [TO_READ_CONFIG] = "RCF", 76 75 [TO_READ_ATTMSG] = "RAT", 77 76 [TO_DIS] = "DIS", [TO_ASSIGN] = "ASS", 78 - [TO_UNASSIGN] = "UAS", [TO_CRYPT_ON] = "CON", 79 - [TO_CRYPT_OFF] = "COF", [TO_KEKL_SET] = "KLS", 80 - [TO_KEKL_QUERY] = "KLQ",[TO_RDC] = "RDC", 77 + [TO_UNASSIGN] = "UAS", [TO_RDC] = "RDC", 81 78 }; 82 79 83 80 static int devid_to_int(struct ccw_dev_id *dev_id) ··· 1311 1312 #endif 1312 1313 DBF_EVENT(3, "tape init\n"); 1313 1314 tape_proc_init(); 1315 + tape_class_init(); 1314 1316 tapechar_init (); 1317 + tape_3490_init(); 1315 1318 return 0; 1316 1319 } 1317 1320 ··· 1326 1325 DBF_EVENT(6, "tape exit\n"); 1327 1326 1328 1327 /* Get rid of the frontends */ 1328 + tape_3490_exit(); 1329 1329 tapechar_exit(); 1330 + tape_class_exit(); 1330 1331 tape_proc_cleanup(); 1331 1332 debug_unregister (TAPE_DBF_AREA); 1332 1333 } 1333 1334 1334 - MODULE_AUTHOR("(C) 2001 IBM Deutschland Entwicklung GmbH by Carsten Otte and " 1335 - "Michael Holzheu (cotte@de.ibm.com,holzheu@de.ibm.com)"); 1336 - MODULE_DESCRIPTION("Linux on zSeries channel attached tape device driver"); 1335 + MODULE_AUTHOR("IBM Corporation"); 1336 + MODULE_DESCRIPTION("s390 channel-attached tape device driver"); 1337 1337 MODULE_LICENSE("GPL"); 1338 1338 1339 1339 module_init(tape_init);
-32
drivers/s390/char/tape_std.c
··· 22 22 #include <asm/types.h> 23 23 #include <asm/idals.h> 24 24 #include <asm/ebcdic.h> 25 - #include <asm/tape390.h> 26 25 27 26 #define TAPE_DBF_AREA tape_core_dbf 28 27 ··· 113 114 } else { 114 115 DBF_EVENT(3, "%08x: Tape unassigned\n", device->cdev_id); 115 116 } 116 - tape_free_request(request); 117 - return rc; 118 - } 119 - 120 - /* 121 - * TAPE390_DISPLAY: Show a string on the tape display. 122 - */ 123 - int 124 - tape_std_display(struct tape_device *device, struct display_struct *disp) 125 - { 126 - struct tape_request *request; 127 - int rc; 128 - 129 - request = tape_alloc_request(2, 17); 130 - if (IS_ERR(request)) { 131 - DBF_EVENT(3, "TAPE: load display failed\n"); 132 - return PTR_ERR(request); 133 - } 134 - request->op = TO_DIS; 135 - 136 - *(unsigned char *) request->cpdata = disp->cntrl; 137 - DBF_EVENT(5, "TAPE: display cntrl=%04x\n", disp->cntrl); 138 - memcpy(((unsigned char *) request->cpdata) + 1, disp->message1, 8); 139 - memcpy(((unsigned char *) request->cpdata) + 9, disp->message2, 8); 140 - ASCEBC(((unsigned char*) request->cpdata) + 1, 16); 141 - 142 - tape_ccw_cc(request->cpaddr, LOAD_DISPLAY, 17, request->cpdata); 143 - tape_ccw_end(request->cpaddr + 1, NOP, 0, NULL); 144 - 145 - rc = tape_do_io_interruptible(device, request); 146 117 tape_free_request(request); 147 118 return rc; 148 119 } ··· 665 696 666 697 EXPORT_SYMBOL(tape_std_assign); 667 698 EXPORT_SYMBOL(tape_std_unassign); 668 - EXPORT_SYMBOL(tape_std_display); 669 699 EXPORT_SYMBOL(tape_std_read_block_id); 670 700 EXPORT_SYMBOL(tape_std_mtload); 671 701 EXPORT_SYMBOL(tape_std_mtsetblk);
+5 -40
drivers/s390/char/tape_std.h
··· 11 11 #ifndef _TAPE_STD_H 12 12 #define _TAPE_STD_H 13 13 14 - #include <asm/tape390.h> 15 - 16 14 /* 17 15 * Biggest block size of 256K to handle. 18 16 */ ··· 19 21 /* 20 22 * The CCW commands for the Tape type of command. 21 23 */ 22 - #define INVALID_00 0x00 /* Invalid cmd */ 23 24 #define BACKSPACEBLOCK 0x27 /* Back Space block */ 24 25 #define BACKSPACEFILE 0x2f /* Back Space file */ 25 26 #define DATA_SEC_ERASE 0x97 /* Data security erase */ 26 27 #define ERASE_GAP 0x17 /* Erase Gap */ 27 28 #define FORSPACEBLOCK 0x37 /* Forward space block */ 28 29 #define FORSPACEFILE 0x3F /* Forward Space file */ 29 - #define FORCE_STREAM_CNT 0xEB /* Forced streaming count # */ 30 30 #define NOP 0x03 /* No operation */ 31 31 #define READ_FORWARD 0x02 /* Read forward */ 32 32 #define REWIND 0x07 /* Rewind */ 33 33 #define REWIND_UNLOAD 0x0F /* Rewind and Unload */ 34 34 #define SENSE 0x04 /* Sense */ 35 - #define NEW_MODE_SET 0xEB /* Guess it is Mode set */ 36 35 #define WRITE_CMD 0x01 /* Write */ 37 36 #define WRITETAPEMARK 0x1F /* Write Tape Mark */ 38 37 39 - #define ASSIGN 0xB7 /* 3420 REJECT,3480 OK */ 40 - #define CONTROL_ACCESS 0xE3 /* Set high speed */ 41 - #define DIAG_MODE_SET 0x0B /* 3420 NOP, 3480 REJECT */ 42 - #define LOAD_DISPLAY 0x9F /* 3420 REJECT,3480 OK */ 43 - #define LOCATE 0x4F /* 3420 REJ, 3480 NOP */ 44 - #define LOOP_WRITE_TO_READ 0x8B /* 3480 REJECT */ 45 - #define MODE_SET_DB 0xDB /* 3420 REJECT,3480 OK */ 46 - #define MODE_SET_C3 0xC3 /* for 3420 */ 47 - #define MODE_SET_CB 0xCB /* for 3420 */ 48 - #define MODE_SET_D3 0xD3 /* for 3420 */ 49 - #define READ_BACKWARD 0x0C /* */ 50 - #define READ_BLOCK_ID 0x22 /* 3420 REJECT,3480 OK */ 51 - #define READ_BUFFER 0x12 /* 3420 REJECT,3480 OK */ 52 - #define READ_BUFF_LOG 0x24 /* 3420 REJECT,3480 OK */ 53 - #define RELEASE 0xD4 /* 3420 NOP, 3480 REJECT */ 54 - #define REQ_TRK_IN_ERROR 0x1B /* 3420 NOP, 3480 REJECT */ 55 - #define RESERVE 0xF4 /* 3420 NOP, 3480 REJECT */ 56 - #define SENSE_GROUP_ID 0x34 /* 3420 REJECT,3480 OK */ 57 - #define SENSE_ID 0xE4 /* 3420 REJECT,3480 OK */ 58 - #define READ_DEV_CHAR 0x64 /* Read device characteristics */ 59 - #define SET_DIAGNOSE 0x4B /* 3420 NOP, 3480 REJECT */ 60 - #define SET_GROUP_ID 0xAF /* 3420 REJECT,3480 OK */ 61 - #define SET_TAPE_WRITE_IMMED 0xC3 /* for 3480 */ 62 - #define SUSPEND 0x5B /* 3420 REJ, 3480 NOP */ 63 - #define SYNC 0x43 /* Synchronize (flush buffer) */ 64 - #define UNASSIGN 0xC7 /* 3420 REJECT,3480 OK */ 65 - #define PERF_SUBSYS_FUNC 0x77 /* 3490 CMD */ 66 - #define READ_CONFIG_DATA 0xFA /* 3490 CMD */ 67 - #define READ_MESSAGE_ID 0x4E /* 3490 CMD */ 68 - #define READ_SUBSYS_DATA 0x3E /* 3490 CMD */ 69 - #define SET_INTERFACE_ID 0x73 /* 3490 CMD */ 38 + #define ASSIGN 0xB7 /* Assign */ 39 + #define LOCATE 0x4F /* Locate Block */ 40 + #define MODE_SET_DB 0xDB /* Mode Set */ 41 + #define READ_BLOCK_ID 0x22 /* Read Block ID */ 42 + #define UNASSIGN 0xC7 /* Unassign */ 70 43 71 44 #define SENSE_COMMAND_REJECT 0x80 72 45 #define SENSE_INTERVENTION_REQUIRED 0x40 ··· 74 105 int tape_std_assign(struct tape_device *); 75 106 int tape_std_unassign(struct tape_device *); 76 107 int tape_std_read_block_id(struct tape_device *device, __u64 *id); 77 - int tape_std_display(struct tape_device *, struct display_struct *disp); 78 108 int tape_std_terminate_write(struct tape_device *); 79 109 80 110 /* Standard magnetic tape commands. */ ··· 101 133 102 134 /* S390 tape types */ 103 135 enum s390_tape_type { 104 - tape_3480, 105 136 tape_3490, 106 - tape_3590, 107 - tape_3592, 108 137 }; 109 138 110 139 #endif // _TAPE_STD_H
+1 -1
drivers/s390/cio/css.c
··· 235 235 return sch; 236 236 237 237 err: 238 - kfree(sch); 238 + put_device(&sch->dev); 239 239 return ERR_PTR(ret); 240 240 } 241 241
+6 -6
drivers/s390/crypto/ap_bus.c
··· 52 52 53 53 int ap_domain_index = -1; /* Adjunct Processor Domain Index */ 54 54 static DEFINE_SPINLOCK(ap_domain_lock); 55 - module_param_named(domain, ap_domain_index, int, 0440); 55 + module_param_named(domain, ap_domain_index, int, 0444); 56 56 MODULE_PARM_DESC(domain, "domain index for ap devices"); 57 57 EXPORT_SYMBOL(ap_domain_index); 58 58 59 59 static int ap_thread_flag; 60 - module_param_named(poll_thread, ap_thread_flag, int, 0440); 60 + module_param_named(poll_thread, ap_thread_flag, int, 0444); 61 61 MODULE_PARM_DESC(poll_thread, "Turn on/off poll thread, default is 0 (off)."); 62 62 63 63 static char *apm_str; 64 - module_param_named(apmask, apm_str, charp, 0440); 64 + module_param_named(apmask, apm_str, charp, 0444); 65 65 MODULE_PARM_DESC(apmask, "AP bus adapter mask."); 66 66 67 67 static char *aqm_str; 68 - module_param_named(aqmask, aqm_str, charp, 0440); 68 + module_param_named(aqmask, aqm_str, charp, 0444); 69 69 MODULE_PARM_DESC(aqmask, "AP bus domain mask."); 70 70 71 71 static int ap_useirq = 1; 72 - module_param_named(useirq, ap_useirq, int, 0440); 72 + module_param_named(useirq, ap_useirq, int, 0444); 73 73 MODULE_PARM_DESC(useirq, "Use interrupt if available, default is 1 (on)."); 74 74 75 75 atomic_t ap_max_msg_size = ATOMIC_INIT(AP_DEFAULT_MAX_MSG_SIZE); ··· 130 130 */ 131 131 static mempool_t *ap_msg_pool; 132 132 static unsigned int ap_msg_pool_min_items = 8; 133 - module_param_named(msgpool_min_items, ap_msg_pool_min_items, uint, 0440); 133 + module_param_named(msgpool_min_items, ap_msg_pool_min_items, uint, 0400); 134 134 MODULE_PARM_DESC(msgpool_min_items, "AP message pool minimal items"); 135 135 136 136 /*
+1 -1
drivers/s390/crypto/zcrypt_api.c
··· 50 50 MODULE_LICENSE("GPL"); 51 51 52 52 unsigned int zcrypt_mempool_threshold = 5; 53 - module_param_named(mempool_threshold, zcrypt_mempool_threshold, uint, 0440); 53 + module_param_named(mempool_threshold, zcrypt_mempool_threshold, uint, 0400); 54 54 MODULE_PARM_DESC(mempool_threshold, "CCA and EP11 request/reply mempool minimal items (min: 1)"); 55 55 56 56 /*