s390: 3590 tape driver
PATCH 20/24 s390: 3590 tape driver
From: Stefan Bader <[email protected]>
From: Michael Holzheu <[email protected]>
From: Martin Schwidefsky <[email protected]>
[patch 20/24] s390: 3590 tape driver
---
drivers/s390/Kconfig | 8 drivers/s390/char/Makefile | 1 drivers/s390/char/tape_34xx.c | 8 drivers/s390/char/tape_3590.c | 1301 ++++++++++++++++++++++++++++++++++++++++++ drivers/s390/char/tape_3590.h | 124 ++++ drivers/s390/char/tape_std.h | 12 6 files changed, 1443 insertions(+), 11 deletions(-)
drivers/s390/char/Makefile +1 -0
@@ -26,4 +26,5 @@ tape-$(CONFIG_PROC_FS) += tape_proc.o tape-objs := tape_core.o tape_std.o tape_char.o $(tape-y) obj-$(CONFIG_S390_TAPE) += tape.o tape_class.o obj-$(CONFIG_S390_TAPE_34XX) += tape_34xx.o +obj-$(CONFIG_S390_TAPE_3590) += tape_3590.o obj-$(CONFIG_MONREADER) += monreader.o
drivers/s390/char/tape_34xx.c +1 -7
@@ -2,8 +2,7 @@* drivers/s390/char/tape_34xx.c * tape device discipline for 3480/3490 tapes. * -* S390 and zSeries version -* Copyright (C) 2001,2002 IBM Deutschland Entwicklung GmbH, IBM Corporation +* Copyright (C) IBM Corp. 2001,2006 * Author(s): Carsten Otte <[email protected]> * Tuan Ngo-Anh <[email protected]> * Martin Schwidefsky <[email protected]>
@@ -28,11 +27,6 @@debug_info_t *TAPE_DBF_AREA =NULL ;EXPORT_SYMBOL (TAPE_DBF_AREA ); -enum tape_34xx_type { - tape_3480, - tape_3490, -}; -#define TAPE34XX_FMT_3480 0#define TAPE34XX_FMT_3480_2_XF 1#define TAPE34XX_FMT_3480_XF 2
drivers/s390/char/tape_3590.c +1301 -0
1,301 lines not on this page · raw message
drivers/s390/char/tape_3590.h +124 -0
124 lines not on this page · raw message
drivers/s390/char/tape_std.h +9 -3
@@ -1,9 +1,8 @@/* -* drivers/s390/char/tape_34xx.h +* drivers/s390/char/tape_std.h * standard tape device functions for ibm tapes. * -* S390 and zSeries version -* Copyright (C) 2001,2002 IBM Deutschland Entwicklung GmbH, IBM Corporation +* Copyright (C) IBM Corp. 2001,2006 * Author(s): Carsten Otte <[email protected]> * Tuan Ngo-Anh <[email protected]> * Martin Schwidefsky <[email protected]>
@@ -149,4 +148,11 @@ void tape_std_error_recovery_do_retry(stvoid tape_std_error_recovery_read_opposite (struct tape_device *);void tape_std_error_recovery_HWBUG (struct tape_device *,int condno); +/* S390 tape types */ +enum s390_tape_type { + tape_3480, + tape_3490, + tape_3590, +}; +#endif // _TAPE_STD_H
drivers/s390/Kconfig +7 -1
@@ -183,7 +183,13 @@ config S390_TAPE_34XX tape subsystems and 100% compatibles. It is safe to say "Y" here. - +config S390_TAPE_3590 + tristate "Support for 3590 tape hardware" + depends on S390_TAPE + help + Select this option if you want to access IBM 3590 magnetic + tape subsystems and 100% compatibles. + It is safe to say "Y" here. config VMLOGRDR tristate "Support for the z/VM recording system services (VM only)"
Quoted 43 lines · Martin Schwidefsky
From: Stefan Bader <[email protected]>
From: Michael Holzheu <[email protected]>
From: Martin Schwidefsky <[email protected]>[patch 20/24] s390: 3590 tape driver
...
drivers/s390/char/tape_3590.c +34
-0+static void +tape_3590_work_handler (void *data) +{ +struct { +struct tape_device *device; +enum tape_op op; +struct work_struct work; + } *p = data; + +switch (p->op) { +case TO_MSEN : +tape_3590_sense_medium (p->device); +break ; +case TO_READ_ATTMSG : +tape_3590_read_attmsg (p->device); +break ; +default : +DBF_EVENT (3 ,"T3590: work handler undefined for " +"operation 0x%02x\n" , p->op); + } +tape_put_device (p->device); +kfree (p); +} + +static int +tape_3590_schedule_work (struct tape_device *device,enum tape_op op) +{ +struct { +struct tape_device *device; +enum tape_op op; +struct work_struct work; + } *p; + +if ((p =kzalloc (sizeof (*p),GFP_ATOMIC )) ==NULL )
drivers/s390/char/tape_3590.c line 276
Quoted 10 lines
drivers/s390/char/tape_3590.c +10
-0+return -ENOMEM ; + +INIT_WORK (&p->work, tape_3590_work_handler, p); + + p->device =tape_get_device_reference (device); + p->op = op; + +schedule_work (&p->work); +return 0 ; +}
That duplicated struct definition is pretty poor form, IMO. Best to have a single definition.
What happens to this driver if the GFP_ATOMIC allocation fails?
I don't see a flush_scheduled_work() in this driver. Is it not possible that there's still work pending at shutdown or rmmod time?
Quoted 45 lines
drivers/s390/char/tape_3590.c +45
-0+#ifdef CONFIG_S390_TAPE_BLOCK +/* +* Tape Block READ +*/ +static struct tape_request * +tape_3590_bread (struct tape_device *device,struct request *req) +{ +struct tape_request *request; +struct ccw1 *ccw; +int count =0 , start_block, i; +unsigned off; +char *dst; +struct bio_vec *bv; +struct bio *bio; + +DBF_EVENT (6 ,"xBREDid:" ); + start_block = req->sector >>TAPEBLOCK_HSEC_S2B ; +DBF_EVENT (6 ,"start_block = %i\n" , start_block); + +rq_for_each_bio (bio, req) { +bio_for_each_segment (bv, bio, i) { + count += bv->bv_len >> (TAPEBLOCK_HSEC_S2B +9 ); + } + } + request =tape_alloc_request (2 + count +1 ,4 ); +if (IS_ERR (request)) +return request; + request->op =TO_BLOCK ; + *(__u32 *) request->cpdata = start_block; + ccw = request->cpaddr; + ccw =tape_ccw_cc (ccw,MODE_SET_DB ,1 , device->modeset_byte); + +/* +* We always setup a nop after the mode set ccw. This slot is +* used in tape_std_check_locate to insert a locate ccw if the +* current tape position doesn't match the start block to be read. +*/ + ccw =tape_ccw_cc (ccw,NOP ,0 ,NULL ); + +rq_for_each_bio (bio, req) { +bio_for_each_segment (bv, bio, i) { + dst =kmap (bv->bv_page) + bv->bv_offset; +for (off =0 ; off < bv->bv_len; + off +=TAPEBLOCK_HSEC_SIZE ) { + ccw->flags =CCW_FLAG_CC ;
drivers/s390/char/tape_3590.c line 332
Quoted 10 lines
drivers/s390/char/tape_3590.c +10
-0+ ccw->cmd_code =READ_FORWARD ; + ccw->count =TAPEBLOCK_HSEC_SIZE ; +set_normalized_cda (ccw, (void *)__pa (dst)); + ccw++; + dst +=TAPEBLOCK_HSEC_SIZE ; + } +if (off > bv->bv_len) +BUG (); + } + }
We seem to be missing a kunmap().