10 #define KMSG_COMPONENT "dasd"
13 #include <linux/stddef.h>
14 #include <linux/kernel.h>
15 #include <linux/slab.h>
18 #include <linux/module.h>
23 #include <asm/debug.h>
33 #define PRINTK_HEADER "dasd(diag):"
42 #define DIAG_MAX_BLOCKS (((2 * PAGE_SIZE - sizeof(struct dasd_ccw_req) - \
43 sizeof(struct dasd_diag_req)) / \
44 sizeof(struct dasd_diag_bio)) / 2)
45 #define DIAG_MAX_RETRIES 32
46 #define DIAG_TIMEOUT 50
63 static const u8 DASD_DIAG_CMS1[] = { 0xc3, 0xd4, 0xe2, 0xf1 };
69 static inline int dia250(
void *
iob,
int cmd)
71 register unsigned long reg2 asm (
"2") = (
unsigned long)
iob;
86 :
"+d" (rc),
"=m" (*(addr_type *) iob)
87 :
"d" (cmd),
"d" (
reg2),
"m" (*(addr_type *) iob)
108 iib->
dev_nr =
private->dev_id.devno;
115 if ((rc & 3) == 0 && end_block)
133 iib->
dev_nr =
private->dev_id.devno;
145 mdsk_term_io(device);
146 rc = mdsk_init_io(device, device->
block->bp_block, 0,
NULL);
149 pr_warning(
"%s: The access mode of a DIAG device "
150 "changed to read-only\n",
151 dev_name(&device->
cdev->dev));
156 "rc=%d\n", dev_name(&device->
cdev->dev), rc);
172 "- no retry left)", cqr);
179 private->iob.dev_nr =
private->dev_id.devno;
180 private->iob.key = 0;
183 private->iob.interrupt_params = (
addr_t) cqr;
184 private->iob.bio_list = dreq->
bio;
191 rc = dia250(&private->iob,
RW_BIO);
207 dasd_diag_erp(device);
222 mdsk_term_io(device);
223 mdsk_init_io(device, device->
block->bp_block, 0,
NULL);
232 unsigned int param32,
unsigned long param64)
236 unsigned long long expires;
241 switch (ext_code.
subcode >> 8) {
261 " magic number of dasd_ccw_req 0x%08X doesn't"
262 " match discipline 0x%08X",
282 if ((ext_code.
subcode & 0xff) == 0) {
289 rc = dasd_start_diag(next);
297 "request %p was %d (%d retries left)", cqr,
299 dasd_diag_erp(device);
322 unsigned int sb, bsize;
328 if (
private ==
NULL) {
330 "Allocating memory for private DASD data "
335 device->
private = (
void *)
private;
340 "could not allocate dasd block structure");
343 return PTR_ERR(block);
346 block->
base = device;
349 rdc_data = (
void *) &(private->rdc_data);
350 rdc_data->
dev_nr =
private->dev_id.devno;
356 "information (rc=%d)", rc);
364 switch (private->rdc_data.vdev_class) {
366 private->pt_block = 1;
369 private->pt_block = 2;
372 pr_warning(
"%s: Device type %d is not supported "
373 "in DIAG mode\n", dev_name(&device->
cdev->dev),
374 private->rdc_data.vdev_class);
380 "%04X: %04X on real %04X/%02X",
386 mdsk_term_io(device);
392 "No memory to allocate initialization request");
399 for (bsize = 512; bsize <=
PAGE_SIZE; bsize <<= 1) {
400 mdsk_init_io(device, bsize, 0, &end_block);
403 bio.block_number =
private->pt_block + 1;
406 private->iob.dev_nr = rdc_data->
dev_nr;
407 private->iob.key = 0;
408 private->iob.flags = 0;
409 private->iob.block_count = 1;
410 private->iob.interrupt_params = 0;
411 private->iob.bio_list = &bio;
413 rc = dia250(&private->iob,
RW_BIO);
416 dev_name(&device->
cdev->dev));
420 mdsk_term_io(device);
425 pr_warning(
"%s: Accessing the DASD failed because of an "
426 "incorrect format (rc=%d)\n",
427 dev_name(&device->
cdev->dev), rc);
433 sizeof(DASD_DIAG_CMS1)) == 0) {
441 for (sb = 512; sb < bsize; sb = sb << 1)
444 if (rc && (rc != 4)) {
445 pr_warning(
"%s: DIAG initialization failed with rc=%d\n",
446 dev_name(&device->
cdev->dev), rc);
451 pr_info(
"%s: New DASD with %ld byte/block, total size %ld "
452 "KB%s\n", dev_name(&device->
cdev->dev),
454 (
unsigned long) (block->
blocks <<
456 (rc == 4) ?
", read-only device" :
"");
476 if (dasd_check_blocksize(block->
bp_block) != 0)
505 struct req_iterator iter;
508 unsigned int count, datasize;
509 sector_t recid, first_rec, last_rec;
510 unsigned int blksize, off;
511 unsigned char rw_cmd;
513 if (rq_data_dir(req) ==
READ)
515 else if (rq_data_dir(req) ==
WRITE)
521 first_rec = blk_rq_pos(req) >> block->
s2b_shift;
523 (blk_rq_pos(req) + blk_rq_sectors(req) - 1) >> block->
s2b_shift;
526 rq_for_each_segment(bv, req, iter) {
527 if (bv->bv_len & (blksize - 1))
530 count += bv->bv_len >> (block->
s2b_shift + 9);
533 if (count != last_rec - first_rec + 1)
546 rq_for_each_segment(bv, req, iter) {
548 for (off = 0; off < bv->bv_len; off += blksize) {
560 if (blk_noretry_request(req) ||
583 static void dasd_diag_handle_terminated_request(
struct dasd_ccw_req *cqr)
596 info->
label_block = (
unsigned int)
private->pt_block;
612 "dump sense not available for DIAG data");
620 .check_device = dasd_diag_check_device,
622 .fill_geometry = dasd_diag_fill_geometry,
623 .start_IO = dasd_start_diag,
624 .term_IO = dasd_diag_term_IO,
625 .handle_terminated_request = dasd_diag_handle_terminated_request,
626 .erp_action = dasd_diag_erp_action,
627 .erp_postaction = dasd_diag_erp_postaction,
628 .build_cp = dasd_diag_build_cp,
629 .free_cp = dasd_diag_free_cp,
630 .dump_sense = dasd_diag_dump_sense,
631 .fill_info = dasd_diag_fill_info,
638 pr_info(
"Discipline %s cannot be used without z/VM\n",
639 dasd_diag_discipline.
name);
651 dasd_diag_cleanup(
void)