Lines Matching +full:max +full:- +full:retries

1 // SPDX-License-Identifier: GPL-2.0
22 #include <asm/asm-extable.h>
43 #define DIAG_MAX_BLOCKS (((2 * PAGE_SIZE - sizeof(struct dasd_ccw_req) - \
100 * number of blocks on the device minus the specified offset. Return non-zero
106 struct dasd_diag_private *private = device->private; in mdsk_init_io()
107 struct dasd_diag_init_io *iib = &private->iib; in mdsk_init_io()
112 iib->dev_nr = private->dev_id.devno; in mdsk_init_io()
113 iib->block_size = blocksize; in mdsk_init_io()
114 iib->offset = offset; in mdsk_init_io()
115 iib->flaga = DASD_DIAG_FLAGA_DEFAULT; in mdsk_init_io()
120 *end_block = iib->end_block; in mdsk_init_io()
125 /* Remove block I/O environment for device. Return zero on success, non-zero
130 struct dasd_diag_private *private = device->private; in mdsk_term_io()
131 struct dasd_diag_init_io *iib = &private->iib; in mdsk_term_io()
135 iib->dev_nr = private->dev_id.devno; in mdsk_term_io()
140 /* Error recovery for failed DIAG requests - try to reestablish the DIAG
148 rc = mdsk_init_io(device, device->block->bp_block, 0, NULL); in dasd_diag_erp()
150 if (!(test_and_set_bit(DASD_FLAG_DEVICE_RO, &device->flags))) in dasd_diag_erp()
151 pr_warn("%s: The access mode of a DIAG device changed to read-only\n", in dasd_diag_erp()
152 dev_name(&device->cdev->dev)); in dasd_diag_erp()
157 dev_name(&device->cdev->dev), rc); in dasd_diag_erp()
160 /* Start a given request at the device. Return zero on success, non-zero
170 device = cqr->startdev; in dasd_start_diag()
171 if (cqr->retries < 0) { in dasd_start_diag()
173 "- no retry left)", cqr); in dasd_start_diag()
174 cqr->status = DASD_CQR_ERROR; in dasd_start_diag()
175 return -EIO; in dasd_start_diag()
177 private = device->private; in dasd_start_diag()
178 dreq = cqr->data; in dasd_start_diag()
180 private->iob.dev_nr = private->dev_id.devno; in dasd_start_diag()
181 private->iob.key = 0; in dasd_start_diag()
182 private->iob.flags = DASD_DIAG_RWFLAG_ASYNC; in dasd_start_diag()
183 private->iob.block_count = dreq->block_count; in dasd_start_diag()
184 private->iob.interrupt_params = (addr_t) cqr; in dasd_start_diag()
185 private->iob.bio_list = dreq->bio; in dasd_start_diag()
186 private->iob.flaga = DASD_DIAG_FLAGA_DEFAULT; in dasd_start_diag()
188 cqr->startclk = get_tod_clock(); in dasd_start_diag()
189 cqr->starttime = jiffies; in dasd_start_diag()
190 cqr->retries--; in dasd_start_diag()
192 rc = dia250(&private->iob, RW_BIO); in dasd_start_diag()
195 cqr->stopclk = get_tod_clock(); in dasd_start_diag()
196 cqr->status = DASD_CQR_SUCCESS; in dasd_start_diag()
199 rc = -EACCES; in dasd_start_diag()
202 cqr->status = DASD_CQR_IN_IO; in dasd_start_diag()
206 cqr->status = DASD_CQR_QUEUED; in dasd_start_diag()
209 rc = -EIO; in dasd_start_diag()
212 cqr->intrc = rc; in dasd_start_diag()
222 device = cqr->startdev; in dasd_diag_term_IO()
224 mdsk_init_io(device, device->block->bp_block, 0, NULL); in dasd_diag_term_IO()
225 cqr->status = DASD_CQR_CLEAR_PENDING; in dasd_diag_term_IO()
226 cqr->stopclk = get_tod_clock(); in dasd_diag_term_IO()
259 device = (struct dasd_device *) cqr->startdev; in dasd_ext_handler()
260 if (strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) { in dasd_ext_handler()
264 cqr->magic, *(int *) (&device->discipline->name)); in dasd_ext_handler()
269 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); in dasd_ext_handler()
272 if (cqr->status == DASD_CQR_CLEAR_PENDING) { in dasd_ext_handler()
273 cqr->status = DASD_CQR_CLEARED; in dasd_ext_handler()
276 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); in dasd_ext_handler()
280 cqr->stopclk = get_tod_clock(); in dasd_ext_handler()
284 cqr->status = DASD_CQR_SUCCESS; in dasd_ext_handler()
285 /* Start first request on queue if possible -> fast_io. */ in dasd_ext_handler()
286 if (!list_empty(&device->ccw_queue)) { in dasd_ext_handler()
287 next = list_entry(device->ccw_queue.next, in dasd_ext_handler()
289 if (next->status == DASD_CQR_QUEUED) { in dasd_ext_handler()
292 expires = next->expires; in dasd_ext_handler()
296 cqr->status = DASD_CQR_QUEUED; in dasd_ext_handler()
298 "request %p was %d (%d retries left)", cqr, in dasd_ext_handler()
299 ext_code.subcode & 0xff, cqr->retries); in dasd_ext_handler()
309 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); in dasd_ext_handler()
313 * success, non-zero otherwise. */
317 struct dasd_diag_private *private = device->private; in dasd_diag_check_device()
332 return -ENOMEM; in dasd_diag_check_device()
334 ccw_device_get_id(device->cdev, &private->dev_id); in dasd_diag_check_device()
335 device->private = private; in dasd_diag_check_device()
341 device->private = NULL; in dasd_diag_check_device()
345 device->block = block; in dasd_diag_check_device()
346 block->base = device; in dasd_diag_check_device()
349 rdc_data = &private->rdc_data; in dasd_diag_check_device()
350 rdc_data->dev_nr = private->dev_id.devno; in dasd_diag_check_device()
351 rdc_data->rdc_len = sizeof (struct dasd_diag_characteristics); in dasd_diag_check_device()
357 rc = -EOPNOTSUPP; in dasd_diag_check_device()
361 device->default_expires = DIAG_TIMEOUT; in dasd_diag_check_device()
362 device->default_retries = DIAG_MAX_RETRIES; in dasd_diag_check_device()
365 switch (private->rdc_data.vdev_class) { in dasd_diag_check_device()
367 private->pt_block = 1; in dasd_diag_check_device()
370 private->pt_block = 2; in dasd_diag_check_device()
374 dev_name(&device->cdev->dev), in dasd_diag_check_device()
375 private->rdc_data.vdev_class); in dasd_diag_check_device()
376 rc = -EOPNOTSUPP; in dasd_diag_check_device()
382 rdc_data->dev_nr, in dasd_diag_check_device()
383 rdc_data->vdev_type, in dasd_diag_check_device()
384 rdc_data->rdev_type, rdc_data->rdev_model); in dasd_diag_check_device()
394 rc = -ENOMEM; in dasd_diag_check_device()
401 rc = -ENOMEM; in dasd_diag_check_device()
406 /* try all sizes - needed for ECKD devices */ in dasd_diag_check_device()
410 bio->type = MDSK_READ_REQ; in dasd_diag_check_device()
411 bio->block_number = private->pt_block + 1; in dasd_diag_check_device()
412 bio->buffer = label; in dasd_diag_check_device()
413 memset(&private->iob, 0, sizeof (struct dasd_diag_rw_io)); in dasd_diag_check_device()
414 private->iob.dev_nr = rdc_data->dev_nr; in dasd_diag_check_device()
415 private->iob.key = 0; in dasd_diag_check_device()
416 private->iob.flags = 0; /* do synchronous io */ in dasd_diag_check_device()
417 private->iob.block_count = 1; in dasd_diag_check_device()
418 private->iob.interrupt_params = 0; in dasd_diag_check_device()
419 private->iob.bio_list = bio; in dasd_diag_check_device()
420 private->iob.flaga = DASD_DIAG_FLAGA_DEFAULT; in dasd_diag_check_device()
421 rc = dia250(&private->iob, RW_BIO); in dasd_diag_check_device()
423 pr_warn("%s: A 64-bit DIAG call failed\n", in dasd_diag_check_device()
424 dev_name(&device->cdev->dev)); in dasd_diag_check_device()
425 rc = -EOPNOTSUPP; in dasd_diag_check_device()
434 dev_name(&device->cdev->dev), rc); in dasd_diag_check_device()
435 rc = -EIO; in dasd_diag_check_device()
439 if (memcmp(label->label_id, DASD_DIAG_CMS1, in dasd_diag_check_device()
442 bsize = (unsigned int) label->block_size; in dasd_diag_check_device()
443 block->blocks = (unsigned long) label->block_count; in dasd_diag_check_device()
445 block->blocks = end_block; in dasd_diag_check_device()
446 block->bp_block = bsize; in dasd_diag_check_device()
447 block->s2b_shift = 0; /* bits to shift 512 to get a block */ in dasd_diag_check_device()
449 block->s2b_shift++; in dasd_diag_check_device()
450 rc = mdsk_init_io(device, block->bp_block, 0, NULL); in dasd_diag_check_device()
453 dev_name(&device->cdev->dev), rc); in dasd_diag_check_device()
454 rc = -EIO; in dasd_diag_check_device()
457 set_bit(DASD_FLAG_DEVICE_RO, &device->flags); in dasd_diag_check_device()
459 "KB%s\n", dev_name(&device->cdev->dev), in dasd_diag_check_device()
460 (unsigned long) block->bp_block, in dasd_diag_check_device()
461 (unsigned long) (block->blocks << in dasd_diag_check_device()
462 block->s2b_shift) >> 1, in dasd_diag_check_device()
463 (rc == 4) ? ", read-only device" : ""); in dasd_diag_check_device()
472 device->block = NULL; in dasd_diag_check_device()
474 device->private = NULL; in dasd_diag_check_device()
480 /* Fill in virtual disk geometry for device. Return zero on success, non-zero
485 if (dasd_check_blocksize(block->bp_block) != 0) in dasd_diag_fill_geometry()
486 return -EINVAL; in dasd_diag_fill_geometry()
487 geo->cylinders = (block->blocks << block->s2b_shift) >> 10; in dasd_diag_fill_geometry()
488 geo->heads = 16; in dasd_diag_fill_geometry()
489 geo->sectors = 128 >> block->s2b_shift; in dasd_diag_fill_geometry()
527 return ERR_PTR(-EINVAL); in dasd_diag_build_cp()
528 blksize = block->bp_block; in dasd_diag_build_cp()
530 first_rec = blk_rq_pos(req) >> block->s2b_shift; in dasd_diag_build_cp()
532 (blk_rq_pos(req) + blk_rq_sectors(req) - 1) >> block->s2b_shift; in dasd_diag_build_cp()
536 if (bv.bv_len & (blksize - 1)) in dasd_diag_build_cp()
538 return ERR_PTR(-EINVAL); in dasd_diag_build_cp()
539 count += bv.bv_len >> (block->s2b_shift + 9); in dasd_diag_build_cp()
542 if (count != last_rec - first_rec + 1) in dasd_diag_build_cp()
543 return ERR_PTR(-EINVAL); in dasd_diag_build_cp()
550 dreq = (struct dasd_diag_req *) cqr->data; in dasd_diag_build_cp()
551 dreq->block_count = count; in dasd_diag_build_cp()
552 dbio = dreq->bio; in dasd_diag_build_cp()
558 dbio->type = rw_cmd; in dasd_diag_build_cp()
559 dbio->block_number = recid + 1; in dasd_diag_build_cp()
560 dbio->buffer = dst; in dasd_diag_build_cp()
566 cqr->retries = memdev->default_retries; in dasd_diag_build_cp()
567 cqr->buildclk = get_tod_clock(); in dasd_diag_build_cp()
569 block->base->features & DASD_FEATURE_FAILFAST) in dasd_diag_build_cp()
570 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags); in dasd_diag_build_cp()
571 cqr->startdev = memdev; in dasd_diag_build_cp()
572 cqr->memdev = memdev; in dasd_diag_build_cp()
573 cqr->block = block; in dasd_diag_build_cp()
574 cqr->expires = memdev->default_expires * HZ; in dasd_diag_build_cp()
575 cqr->status = DASD_CQR_FILLED; in dasd_diag_build_cp()
579 /* Release DASD request. Return non-zero if request was successful, zero
586 status = cqr->status == DASD_CQR_DONE; in dasd_diag_free_cp()
587 dasd_sfree_request(cqr, cqr->memdev); in dasd_diag_free_cp()
593 if (cqr->retries < 0) in dasd_diag_handle_terminated_request()
594 cqr->status = DASD_CQR_FAILED; in dasd_diag_handle_terminated_request()
596 cqr->status = DASD_CQR_FILLED; in dasd_diag_handle_terminated_request()
604 struct dasd_diag_private *private = device->private; in dasd_diag_fill_info()
606 info->label_block = (unsigned int) private->pt_block; in dasd_diag_fill_info()
607 info->FBA_layout = 1; in dasd_diag_fill_info()
608 info->format = DASD_FORMAT_LDL; in dasd_diag_fill_info()
609 info->characteristics_size = sizeof(private->rdc_data); in dasd_diag_fill_info()
610 memcpy(info->characteristics, &private->rdc_data, in dasd_diag_fill_info()
611 sizeof(private->rdc_data)); in dasd_diag_fill_info()
612 info->confdata_size = 0; in dasd_diag_fill_info()
629 unsigned int logical_block_size = block->bp_block; in dasd_diag_setup_blk_queue()
630 struct request_queue *q = block->gdp->queue; in dasd_diag_setup_blk_queue()
631 int max; in dasd_diag_setup_blk_queue() local
633 max = DIAG_MAX_BLOCKS << block->s2b_shift; in dasd_diag_setup_blk_queue()
635 q->limits.max_dev_sectors = max; in dasd_diag_setup_blk_queue()
637 blk_queue_max_hw_sectors(q, max); in dasd_diag_setup_blk_queue()
641 blk_queue_segment_boundary(q, PAGE_SIZE - 1); in dasd_diag_setup_blk_queue()
675 return -ENODEV; in dasd_diag_init()