2 * File...........: linux/drivers/s390/block/dasd.c
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Horst Hummel <Horst.Hummel@de.ibm.com>
5 * Carsten Otte <Cotte@de.ibm.com>
6 * Martin Schwidefsky <schwidefsky@de.ibm.com>
7 * Bugreports.to..: <Linux390@de.ibm.com>
8 * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999-2001
12 #include <linux/kmod.h>
13 #include <linux/init.h>
14 #include <linux/interrupt.h>
15 #include <linux/ctype.h>
16 #include <linux/major.h>
17 #include <linux/slab.h>
18 #include <linux/buffer_head.h>
19 #include <linux/hdreg.h>
21 #include <asm/ccwdev.h>
22 #include <asm/ebcdic.h>
23 #include <asm/idals.h>
24 #include <asm/todclk.h>
27 #define PRINTK_HEADER "dasd:"
31 * SECTION: Constant definitions to be used within this file
33 #define DASD_CHANQ_MAX_SIZE 4
36 * SECTION: exported variables of dasd.c
38 debug_info_t *dasd_debug_area;
39 struct dasd_discipline *dasd_diag_discipline_pointer;
40 void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *);
42 MODULE_AUTHOR("Holger Smolinski <Holger.Smolinski@de.ibm.com>");
43 MODULE_DESCRIPTION("Linux on S/390 DASD device driver,"
44 " Copyright 2000 IBM Corporation");
45 MODULE_SUPPORTED_DEVICE("dasd");
46 MODULE_LICENSE("GPL");
49 * SECTION: prototypes for static functions of dasd.c
51 static int dasd_alloc_queue(struct dasd_block *);
52 static void dasd_setup_queue(struct dasd_block *);
53 static void dasd_free_queue(struct dasd_block *);
54 static void dasd_flush_request_queue(struct dasd_block *);
55 static int dasd_flush_block_queue(struct dasd_block *);
56 static void dasd_device_tasklet(struct dasd_device *);
57 static void dasd_block_tasklet(struct dasd_block *);
58 static void do_kick_device(struct work_struct *);
59 static void dasd_return_cqr_cb(struct dasd_ccw_req *, void *);
62 * SECTION: Operations on the device structure.
64 static wait_queue_head_t dasd_init_waitq;
65 static wait_queue_head_t dasd_flush_wq;
66 static wait_queue_head_t generic_waitq;
69 * Allocate memory for a new device structure.
71 struct dasd_device *dasd_alloc_device(void)
73 struct dasd_device *device;
75 device = kzalloc(sizeof(struct dasd_device), GFP_ATOMIC);
77 return ERR_PTR(-ENOMEM);
79 /* Get two pages for normal block device operations. */
80 device->ccw_mem = (void *) __get_free_pages(GFP_ATOMIC | GFP_DMA, 1);
81 if (!device->ccw_mem) {
83 return ERR_PTR(-ENOMEM);
85 /* Get one page for error recovery. */
86 device->erp_mem = (void *) get_zeroed_page(GFP_ATOMIC | GFP_DMA);
87 if (!device->erp_mem) {
88 free_pages((unsigned long) device->ccw_mem, 1);
90 return ERR_PTR(-ENOMEM);
93 dasd_init_chunklist(&device->ccw_chunks, device->ccw_mem, PAGE_SIZE*2);
94 dasd_init_chunklist(&device->erp_chunks, device->erp_mem, PAGE_SIZE);
95 spin_lock_init(&device->mem_lock);
96 atomic_set(&device->tasklet_scheduled, 0);
97 tasklet_init(&device->tasklet,
98 (void (*)(unsigned long)) dasd_device_tasklet,
99 (unsigned long) device);
100 INIT_LIST_HEAD(&device->ccw_queue);
101 init_timer(&device->timer);
102 INIT_WORK(&device->kick_work, do_kick_device);
103 device->state = DASD_STATE_NEW;
104 device->target = DASD_STATE_NEW;
110 * Free memory of a device structure.
112 void dasd_free_device(struct dasd_device *device)
114 kfree(device->private);
115 free_page((unsigned long) device->erp_mem);
116 free_pages((unsigned long) device->ccw_mem, 1);
121 * Allocate memory for a new device structure.
123 struct dasd_block *dasd_alloc_block(void)
125 struct dasd_block *block;
127 block = kzalloc(sizeof(*block), GFP_ATOMIC);
129 return ERR_PTR(-ENOMEM);
130 /* open_count = 0 means device online but not in use */
131 atomic_set(&block->open_count, -1);
133 spin_lock_init(&block->request_queue_lock);
134 atomic_set(&block->tasklet_scheduled, 0);
135 tasklet_init(&block->tasklet,
136 (void (*)(unsigned long)) dasd_block_tasklet,
137 (unsigned long) block);
138 INIT_LIST_HEAD(&block->ccw_queue);
139 spin_lock_init(&block->queue_lock);
140 init_timer(&block->timer);
146 * Free memory of a device structure.
148 void dasd_free_block(struct dasd_block *block)
154 * Make a new device known to the system.
156 static int dasd_state_new_to_known(struct dasd_device *device)
161 * As long as the device is not in state DASD_STATE_NEW we want to
162 * keep the reference count > 0.
164 dasd_get_device(device);
167 rc = dasd_alloc_queue(device->block);
169 dasd_put_device(device);
173 device->state = DASD_STATE_KNOWN;
178 * Let the system forget about a device.
180 static int dasd_state_known_to_new(struct dasd_device *device)
182 /* Disable extended error reporting for this device. */
183 dasd_eer_disable(device);
184 /* Forget the discipline information. */
185 if (device->discipline) {
186 if (device->discipline->uncheck_device)
187 device->discipline->uncheck_device(device);
188 module_put(device->discipline->owner);
190 device->discipline = NULL;
191 if (device->base_discipline)
192 module_put(device->base_discipline->owner);
193 device->base_discipline = NULL;
194 device->state = DASD_STATE_NEW;
197 dasd_free_queue(device->block);
199 /* Give up reference we took in dasd_state_new_to_known. */
200 dasd_put_device(device);
205 * Request the irq line for the device.
207 static int dasd_state_known_to_basic(struct dasd_device *device)
211 /* Allocate and register gendisk structure. */
213 rc = dasd_gendisk_alloc(device->block);
217 /* register 'device' debug area, used for all DBF_DEV_XXX calls */
218 device->debug_area = debug_register(dev_name(&device->cdev->dev), 1, 1,
220 debug_register_view(device->debug_area, &debug_sprintf_view);
221 debug_set_level(device->debug_area, DBF_WARNING);
222 DBF_DEV_EVENT(DBF_EMERG, device, "%s", "debug area created");
224 device->state = DASD_STATE_BASIC;
229 * Release the irq line for the device. Terminate any running i/o.
231 static int dasd_state_basic_to_known(struct dasd_device *device)
235 dasd_gendisk_free(device->block);
236 dasd_block_clear_timer(device->block);
238 rc = dasd_flush_device_queue(device);
241 dasd_device_clear_timer(device);
243 DBF_DEV_EVENT(DBF_EMERG, device, "%p debug area deleted", device);
244 if (device->debug_area != NULL) {
245 debug_unregister(device->debug_area);
246 device->debug_area = NULL;
248 device->state = DASD_STATE_KNOWN;
253 * Do the initial analysis. The do_analysis function may return
254 * -EAGAIN in which case the device keeps the state DASD_STATE_BASIC
255 * until the discipline decides to continue the startup sequence
256 * by calling the function dasd_change_state. The eckd disciplines
257 * uses this to start a ccw that detects the format. The completion
258 * interrupt for this detection ccw uses the kernel event daemon to
259 * trigger the call to dasd_change_state. All this is done in the
260 * discipline code, see dasd_eckd.c.
261 * After the analysis ccw is done (do_analysis returned 0) the block
263 * In case the analysis returns an error, the device setup is stopped
264 * (a fake disk was already added to allow formatting).
266 static int dasd_state_basic_to_ready(struct dasd_device *device)
269 struct dasd_block *block;
272 block = device->block;
273 /* make disk known with correct capacity */
275 if (block->base->discipline->do_analysis != NULL)
276 rc = block->base->discipline->do_analysis(block);
279 device->state = DASD_STATE_UNFMT;
282 dasd_setup_queue(block);
283 set_capacity(block->gdp,
284 block->blocks << block->s2b_shift);
285 device->state = DASD_STATE_READY;
286 rc = dasd_scan_partitions(block);
288 device->state = DASD_STATE_BASIC;
290 device->state = DASD_STATE_READY;
296 * Remove device from block device layer. Destroy dirty buffers.
297 * Forget format information. Check if the target level is basic
298 * and if it is create fake disk for formatting.
300 static int dasd_state_ready_to_basic(struct dasd_device *device)
304 device->state = DASD_STATE_BASIC;
306 struct dasd_block *block = device->block;
307 rc = dasd_flush_block_queue(block);
309 device->state = DASD_STATE_READY;
312 dasd_destroy_partitions(block);
313 dasd_flush_request_queue(block);
316 block->s2b_shift = 0;
324 static int dasd_state_unfmt_to_basic(struct dasd_device *device)
326 device->state = DASD_STATE_BASIC;
331 * Make the device online and schedule the bottom half to start
332 * the requeueing of requests from the linux request queue to the
336 dasd_state_ready_to_online(struct dasd_device * device)
339 struct gendisk *disk;
340 struct disk_part_iter piter;
341 struct hd_struct *part;
343 if (device->discipline->ready_to_online) {
344 rc = device->discipline->ready_to_online(device);
348 device->state = DASD_STATE_ONLINE;
350 dasd_schedule_block_bh(device->block);
351 disk = device->block->bdev->bd_disk;
352 disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
353 while ((part = disk_part_iter_next(&piter)))
354 kobject_uevent(&part_to_dev(part)->kobj, KOBJ_CHANGE);
355 disk_part_iter_exit(&piter);
361 * Stop the requeueing of requests again.
363 static int dasd_state_online_to_ready(struct dasd_device *device)
366 struct gendisk *disk;
367 struct disk_part_iter piter;
368 struct hd_struct *part;
370 if (device->discipline->online_to_ready) {
371 rc = device->discipline->online_to_ready(device);
375 device->state = DASD_STATE_READY;
377 disk = device->block->bdev->bd_disk;
378 disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
379 while ((part = disk_part_iter_next(&piter)))
380 kobject_uevent(&part_to_dev(part)->kobj, KOBJ_CHANGE);
381 disk_part_iter_exit(&piter);
387 * Device startup state changes.
389 static int dasd_increase_state(struct dasd_device *device)
394 if (device->state == DASD_STATE_NEW &&
395 device->target >= DASD_STATE_KNOWN)
396 rc = dasd_state_new_to_known(device);
399 device->state == DASD_STATE_KNOWN &&
400 device->target >= DASD_STATE_BASIC)
401 rc = dasd_state_known_to_basic(device);
404 device->state == DASD_STATE_BASIC &&
405 device->target >= DASD_STATE_READY)
406 rc = dasd_state_basic_to_ready(device);
409 device->state == DASD_STATE_UNFMT &&
410 device->target > DASD_STATE_UNFMT)
414 device->state == DASD_STATE_READY &&
415 device->target >= DASD_STATE_ONLINE)
416 rc = dasd_state_ready_to_online(device);
422 * Device shutdown state changes.
424 static int dasd_decrease_state(struct dasd_device *device)
429 if (device->state == DASD_STATE_ONLINE &&
430 device->target <= DASD_STATE_READY)
431 rc = dasd_state_online_to_ready(device);
434 device->state == DASD_STATE_READY &&
435 device->target <= DASD_STATE_BASIC)
436 rc = dasd_state_ready_to_basic(device);
439 device->state == DASD_STATE_UNFMT &&
440 device->target <= DASD_STATE_BASIC)
441 rc = dasd_state_unfmt_to_basic(device);
444 device->state == DASD_STATE_BASIC &&
445 device->target <= DASD_STATE_KNOWN)
446 rc = dasd_state_basic_to_known(device);
449 device->state == DASD_STATE_KNOWN &&
450 device->target <= DASD_STATE_NEW)
451 rc = dasd_state_known_to_new(device);
457 * This is the main startup/shutdown routine.
459 static void dasd_change_state(struct dasd_device *device)
463 if (device->state == device->target)
464 /* Already where we want to go today... */
466 if (device->state < device->target)
467 rc = dasd_increase_state(device);
469 rc = dasd_decrease_state(device);
470 if (rc && rc != -EAGAIN)
471 device->target = device->state;
473 if (device->state == device->target)
474 wake_up(&dasd_init_waitq);
476 /* let user-space know that the device status changed */
477 kobject_uevent(&device->cdev->dev.kobj, KOBJ_CHANGE);
481 * Kick starter for devices that did not complete the startup/shutdown
482 * procedure or were sleeping because of a pending state.
483 * dasd_kick_device will schedule a call do do_kick_device to the kernel
486 static void do_kick_device(struct work_struct *work)
488 struct dasd_device *device = container_of(work, struct dasd_device, kick_work);
489 dasd_change_state(device);
490 dasd_schedule_device_bh(device);
491 dasd_put_device(device);
494 void dasd_kick_device(struct dasd_device *device)
496 dasd_get_device(device);
497 /* queue call to dasd_kick_device to the kernel event daemon. */
498 schedule_work(&device->kick_work);
502 * Set the target state for a device and starts the state change.
504 void dasd_set_target_state(struct dasd_device *device, int target)
506 /* If we are in probeonly mode stop at DASD_STATE_READY. */
507 if (dasd_probeonly && target > DASD_STATE_READY)
508 target = DASD_STATE_READY;
509 if (device->target != target) {
510 if (device->state == target)
511 wake_up(&dasd_init_waitq);
512 device->target = target;
514 if (device->state != device->target)
515 dasd_change_state(device);
519 * Enable devices with device numbers in [from..to].
521 static inline int _wait_for_device(struct dasd_device *device)
523 return (device->state == device->target);
526 void dasd_enable_device(struct dasd_device *device)
528 dasd_set_target_state(device, DASD_STATE_ONLINE);
529 if (device->state <= DASD_STATE_KNOWN)
530 /* No discipline for device found. */
531 dasd_set_target_state(device, DASD_STATE_NEW);
532 /* Now wait for the devices to come up. */
533 wait_event(dasd_init_waitq, _wait_for_device(device));
537 * SECTION: device operation (interrupt handler, start i/o, term i/o ...)
539 #ifdef CONFIG_DASD_PROFILE
541 struct dasd_profile_info_t dasd_global_profile;
542 unsigned int dasd_profile_level = DASD_PROFILE_OFF;
545 * Increments counter in global and local profiling structures.
547 #define dasd_profile_counter(value, counter, block) \
550 for (index = 0; index < 31 && value >> (2+index); index++); \
551 dasd_global_profile.counter[index]++; \
552 block->profile.counter[index]++; \
556 * Add profiling information for cqr before execution.
558 static void dasd_profile_start(struct dasd_block *block,
559 struct dasd_ccw_req *cqr,
563 unsigned int counter;
565 if (dasd_profile_level != DASD_PROFILE_ON)
568 /* count the length of the chanq for statistics */
570 list_for_each(l, &block->ccw_queue)
573 dasd_global_profile.dasd_io_nr_req[counter]++;
574 block->profile.dasd_io_nr_req[counter]++;
578 * Add profiling information for cqr after execution.
580 static void dasd_profile_end(struct dasd_block *block,
581 struct dasd_ccw_req *cqr,
584 long strtime, irqtime, endtime, tottime; /* in microseconds */
585 long tottimeps, sectors;
587 if (dasd_profile_level != DASD_PROFILE_ON)
590 sectors = req->nr_sectors;
591 if (!cqr->buildclk || !cqr->startclk ||
592 !cqr->stopclk || !cqr->endclk ||
596 strtime = ((cqr->startclk - cqr->buildclk) >> 12);
597 irqtime = ((cqr->stopclk - cqr->startclk) >> 12);
598 endtime = ((cqr->endclk - cqr->stopclk) >> 12);
599 tottime = ((cqr->endclk - cqr->buildclk) >> 12);
600 tottimeps = tottime / sectors;
602 if (!dasd_global_profile.dasd_io_reqs)
603 memset(&dasd_global_profile, 0,
604 sizeof(struct dasd_profile_info_t));
605 dasd_global_profile.dasd_io_reqs++;
606 dasd_global_profile.dasd_io_sects += sectors;
608 if (!block->profile.dasd_io_reqs)
609 memset(&block->profile, 0,
610 sizeof(struct dasd_profile_info_t));
611 block->profile.dasd_io_reqs++;
612 block->profile.dasd_io_sects += sectors;
614 dasd_profile_counter(sectors, dasd_io_secs, block);
615 dasd_profile_counter(tottime, dasd_io_times, block);
616 dasd_profile_counter(tottimeps, dasd_io_timps, block);
617 dasd_profile_counter(strtime, dasd_io_time1, block);
618 dasd_profile_counter(irqtime, dasd_io_time2, block);
619 dasd_profile_counter(irqtime / sectors, dasd_io_time2ps, block);
620 dasd_profile_counter(endtime, dasd_io_time3, block);
623 #define dasd_profile_start(block, cqr, req) do {} while (0)
624 #define dasd_profile_end(block, cqr, req) do {} while (0)
625 #endif /* CONFIG_DASD_PROFILE */
628 * Allocate memory for a channel program with 'cplength' channel
629 * command words and 'datasize' additional space. There are two
630 * variantes: 1) dasd_kmalloc_request uses kmalloc to get the needed
631 * memory and 2) dasd_smalloc_request uses the static ccw memory
632 * that gets allocated for each device.
634 struct dasd_ccw_req *dasd_kmalloc_request(char *magic, int cplength,
636 struct dasd_device *device)
638 struct dasd_ccw_req *cqr;
641 BUG_ON( magic == NULL || datasize > PAGE_SIZE ||
642 (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
644 cqr = kzalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC);
646 return ERR_PTR(-ENOMEM);
649 cqr->cpaddr = kcalloc(cplength, sizeof(struct ccw1),
650 GFP_ATOMIC | GFP_DMA);
651 if (cqr->cpaddr == NULL) {
653 return ERR_PTR(-ENOMEM);
658 cqr->data = kzalloc(datasize, GFP_ATOMIC | GFP_DMA);
659 if (cqr->data == NULL) {
662 return ERR_PTR(-ENOMEM);
665 strncpy((char *) &cqr->magic, magic, 4);
666 ASCEBC((char *) &cqr->magic, 4);
667 set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
668 dasd_get_device(device);
672 struct dasd_ccw_req *dasd_smalloc_request(char *magic, int cplength,
674 struct dasd_device *device)
677 struct dasd_ccw_req *cqr;
682 BUG_ON( magic == NULL || datasize > PAGE_SIZE ||
683 (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
685 size = (sizeof(struct dasd_ccw_req) + 7L) & -8L;
687 size += cplength * sizeof(struct ccw1);
690 spin_lock_irqsave(&device->mem_lock, flags);
691 cqr = (struct dasd_ccw_req *)
692 dasd_alloc_chunk(&device->ccw_chunks, size);
693 spin_unlock_irqrestore(&device->mem_lock, flags);
695 return ERR_PTR(-ENOMEM);
696 memset(cqr, 0, sizeof(struct dasd_ccw_req));
697 data = (char *) cqr + ((sizeof(struct dasd_ccw_req) + 7L) & -8L);
700 cqr->cpaddr = (struct ccw1 *) data;
701 data += cplength*sizeof(struct ccw1);
702 memset(cqr->cpaddr, 0, cplength*sizeof(struct ccw1));
707 memset(cqr->data, 0, datasize);
709 strncpy((char *) &cqr->magic, magic, 4);
710 ASCEBC((char *) &cqr->magic, 4);
711 set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
712 dasd_get_device(device);
717 * Free memory of a channel program. This function needs to free all the
718 * idal lists that might have been created by dasd_set_cda and the
719 * struct dasd_ccw_req itself.
721 void dasd_kfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device)
726 /* Clear any idals used for the request. */
729 clear_normalized_cda(ccw);
730 } while (ccw++->flags & (CCW_FLAG_CC | CCW_FLAG_DC));
735 dasd_put_device(device);
738 void dasd_sfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device)
742 spin_lock_irqsave(&device->mem_lock, flags);
743 dasd_free_chunk(&device->ccw_chunks, cqr);
744 spin_unlock_irqrestore(&device->mem_lock, flags);
745 dasd_put_device(device);
749 * Check discipline magic in cqr.
751 static inline int dasd_check_cqr(struct dasd_ccw_req *cqr)
753 struct dasd_device *device;
757 device = cqr->startdev;
758 if (strncmp((char *) &cqr->magic, device->discipline->ebcname, 4)) {
759 DEV_MESSAGE(KERN_WARNING, device,
760 " dasd_ccw_req 0x%08x magic doesn't match"
761 " discipline 0x%08x",
763 *(unsigned int *) device->discipline->name);
770 * Terminate the current i/o and set the request to clear_pending.
771 * Timer keeps device runnig.
772 * ccw_device_clear can fail if the i/o subsystem
775 int dasd_term_IO(struct dasd_ccw_req *cqr)
777 struct dasd_device *device;
781 rc = dasd_check_cqr(cqr);
785 device = (struct dasd_device *) cqr->startdev;
786 while ((retries < 5) && (cqr->status == DASD_CQR_IN_IO)) {
787 rc = ccw_device_clear(device->cdev, (long) cqr);
789 case 0: /* termination successful */
791 cqr->status = DASD_CQR_CLEAR_PENDING;
792 cqr->stopclk = get_clock();
794 DBF_DEV_EVENT(DBF_DEBUG, device,
795 "terminate cqr %p successful",
799 DBF_DEV_EVENT(DBF_ERR, device, "%s",
800 "device gone, retry");
803 DBF_DEV_EVENT(DBF_ERR, device, "%s",
808 DBF_DEV_EVENT(DBF_ERR, device, "%s",
809 "device busy, retry later");
812 DEV_MESSAGE(KERN_ERR, device,
813 "line %d unknown RC=%d, please "
814 "report to linux390@de.ibm.com",
821 dasd_schedule_device_bh(device);
826 * Start the i/o. This start_IO can fail if the channel is really busy.
827 * In that case set up a timer to start the request later.
829 int dasd_start_IO(struct dasd_ccw_req *cqr)
831 struct dasd_device *device;
835 rc = dasd_check_cqr(cqr);
838 device = (struct dasd_device *) cqr->startdev;
839 if (cqr->retries < 0) {
840 DEV_MESSAGE(KERN_DEBUG, device,
841 "start_IO: request %p (%02x/%i) - no retry left.",
842 cqr, cqr->status, cqr->retries);
843 cqr->status = DASD_CQR_ERROR;
846 cqr->startclk = get_clock();
847 cqr->starttime = jiffies;
849 rc = ccw_device_start(device->cdev, cqr->cpaddr, (long) cqr,
853 cqr->status = DASD_CQR_IN_IO;
854 DBF_DEV_EVENT(DBF_DEBUG, device,
855 "start_IO: request %p started successful",
859 DBF_DEV_EVENT(DBF_ERR, device, "%s",
860 "start_IO: device busy, retry later");
863 DBF_DEV_EVENT(DBF_ERR, device, "%s",
864 "start_IO: request timeout, retry later");
867 /* -EACCES indicates that the request used only a
868 * subset of the available pathes and all these
870 * Do a retry with all available pathes.
872 cqr->lpm = LPM_ANYPATH;
873 DBF_DEV_EVENT(DBF_ERR, device, "%s",
874 "start_IO: selected pathes gone,"
875 " retry on all pathes");
879 DBF_DEV_EVENT(DBF_ERR, device, "%s",
880 "start_IO: device gone, retry");
883 DEV_MESSAGE(KERN_ERR, device,
884 "line %d unknown RC=%d, please report"
885 " to linux390@de.ibm.com", __LINE__, rc);
893 * Timeout function for dasd devices. This is used for different purposes
894 * 1) missing interrupt handler for normal operation
895 * 2) delayed start of request where start_IO failed with -EBUSY
896 * 3) timeout for missing state change interrupts
897 * The head of the ccw queue will have status DASD_CQR_IN_IO for 1),
898 * DASD_CQR_QUEUED for 2) and 3).
900 static void dasd_device_timeout(unsigned long ptr)
903 struct dasd_device *device;
905 device = (struct dasd_device *) ptr;
906 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
907 /* re-activate request queue */
908 device->stopped &= ~DASD_STOPPED_PENDING;
909 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
910 dasd_schedule_device_bh(device);
914 * Setup timeout for a device in jiffies.
916 void dasd_device_set_timer(struct dasd_device *device, int expires)
919 if (timer_pending(&device->timer))
920 del_timer(&device->timer);
923 if (timer_pending(&device->timer)) {
924 if (mod_timer(&device->timer, jiffies + expires))
927 device->timer.function = dasd_device_timeout;
928 device->timer.data = (unsigned long) device;
929 device->timer.expires = jiffies + expires;
930 add_timer(&device->timer);
934 * Clear timeout for a device.
936 void dasd_device_clear_timer(struct dasd_device *device)
938 if (timer_pending(&device->timer))
939 del_timer(&device->timer);
942 static void dasd_handle_killed_request(struct ccw_device *cdev,
943 unsigned long intparm)
945 struct dasd_ccw_req *cqr;
946 struct dasd_device *device;
950 cqr = (struct dasd_ccw_req *) intparm;
951 if (cqr->status != DASD_CQR_IN_IO) {
953 "invalid status in handle_killed_request: "
954 "bus_id %s, status %02x",
955 dev_name(&cdev->dev), cqr->status);
959 device = (struct dasd_device *) cqr->startdev;
960 if (device == NULL ||
961 device != dasd_device_from_cdev_locked(cdev) ||
962 strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) {
963 MESSAGE(KERN_DEBUG, "invalid device in request: bus_id %s",
964 dev_name(&cdev->dev));
968 /* Schedule request to be retried. */
969 cqr->status = DASD_CQR_QUEUED;
971 dasd_device_clear_timer(device);
972 dasd_schedule_device_bh(device);
973 dasd_put_device(device);
976 void dasd_generic_handle_state_change(struct dasd_device *device)
978 /* First of all start sense subsystem status request. */
979 dasd_eer_snss(device);
981 device->stopped &= ~DASD_STOPPED_PENDING;
982 dasd_schedule_device_bh(device);
984 dasd_schedule_block_bh(device->block);
988 * Interrupt handler for "normal" ssch-io based dasd devices.
990 void dasd_int_handler(struct ccw_device *cdev, unsigned long intparm,
993 struct dasd_ccw_req *cqr, *next;
994 struct dasd_device *device;
995 unsigned long long now;
999 switch (PTR_ERR(irb)) {
1003 printk(KERN_WARNING"%s(%s): request timed out\n",
1004 __func__, dev_name(&cdev->dev));
1007 printk(KERN_WARNING"%s(%s): unknown error %ld\n",
1008 __func__, dev_name(&cdev->dev), PTR_ERR(irb));
1010 dasd_handle_killed_request(cdev, intparm);
1016 DBF_EVENT(DBF_ERR, "Interrupt: bus_id %s CS/DS %04x ip %08x",
1017 dev_name(&cdev->dev), ((irb->scsw.cmd.cstat << 8) |
1018 irb->scsw.cmd.dstat), (unsigned int) intparm);
1020 /* check for unsolicited interrupts */
1021 cqr = (struct dasd_ccw_req *) intparm;
1022 if (!cqr || ((irb->scsw.cmd.cc == 1) &&
1023 (irb->scsw.cmd.fctl & SCSW_FCTL_START_FUNC) &&
1024 (irb->scsw.cmd.stctl & SCSW_STCTL_STATUS_PEND))) {
1025 if (cqr && cqr->status == DASD_CQR_IN_IO)
1026 cqr->status = DASD_CQR_QUEUED;
1027 device = dasd_device_from_cdev_locked(cdev);
1028 if (!IS_ERR(device)) {
1029 dasd_device_clear_timer(device);
1030 device->discipline->handle_unsolicited_interrupt(device,
1032 dasd_put_device(device);
1037 device = (struct dasd_device *) cqr->startdev;
1039 strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) {
1040 MESSAGE(KERN_DEBUG, "invalid device in request: bus_id %s",
1041 dev_name(&cdev->dev));
1045 /* Check for clear pending */
1046 if (cqr->status == DASD_CQR_CLEAR_PENDING &&
1047 irb->scsw.cmd.fctl & SCSW_FCTL_CLEAR_FUNC) {
1048 cqr->status = DASD_CQR_CLEARED;
1049 dasd_device_clear_timer(device);
1050 wake_up(&dasd_flush_wq);
1051 dasd_schedule_device_bh(device);
1055 /* check status - the request might have been killed by dyn detach */
1056 if (cqr->status != DASD_CQR_IN_IO) {
1058 "invalid status: bus_id %s, status %02x",
1059 dev_name(&cdev->dev), cqr->status);
1062 DBF_DEV_EVENT(DBF_DEBUG, device, "Int: CS/DS 0x%04x for cqr %p",
1063 ((irb->scsw.cmd.cstat << 8) | irb->scsw.cmd.dstat), cqr);
1066 if (irb->scsw.cmd.dstat == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) &&
1067 irb->scsw.cmd.cstat == 0 && !irb->esw.esw0.erw.cons) {
1068 /* request was completed successfully */
1069 cqr->status = DASD_CQR_SUCCESS;
1071 /* Start first request on queue if possible -> fast_io. */
1072 if (cqr->devlist.next != &device->ccw_queue) {
1073 next = list_entry(cqr->devlist.next,
1074 struct dasd_ccw_req, devlist);
1076 } else { /* error */
1077 memcpy(&cqr->irb, irb, sizeof(struct irb));
1078 if (device->features & DASD_FEATURE_ERPLOG) {
1079 dasd_log_sense(cqr, irb);
1082 * If we don't want complex ERP for this request, then just
1083 * reset this and retry it in the fastpath
1085 if (!test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags) &&
1087 DEV_MESSAGE(KERN_DEBUG, device,
1088 "default ERP in fastpath (%i retries left)",
1090 cqr->lpm = LPM_ANYPATH;
1091 cqr->status = DASD_CQR_QUEUED;
1094 cqr->status = DASD_CQR_ERROR;
1096 if (next && (next->status == DASD_CQR_QUEUED) &&
1097 (!device->stopped)) {
1098 if (device->discipline->start_IO(next) == 0)
1099 expires = next->expires;
1101 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1102 "Interrupt fastpath "
1106 dasd_device_set_timer(device, expires);
1108 dasd_device_clear_timer(device);
1109 dasd_schedule_device_bh(device);
1113 * If we have an error on a dasd_block layer request then we cancel
1114 * and return all further requests from the same dasd_block as well.
1116 static void __dasd_device_recovery(struct dasd_device *device,
1117 struct dasd_ccw_req *ref_cqr)
1119 struct list_head *l, *n;
1120 struct dasd_ccw_req *cqr;
1123 * only requeue request that came from the dasd_block layer
1125 if (!ref_cqr->block)
1128 list_for_each_safe(l, n, &device->ccw_queue) {
1129 cqr = list_entry(l, struct dasd_ccw_req, devlist);
1130 if (cqr->status == DASD_CQR_QUEUED &&
1131 ref_cqr->block == cqr->block) {
1132 cqr->status = DASD_CQR_CLEARED;
1138 * Remove those ccw requests from the queue that need to be returned
1139 * to the upper layer.
1141 static void __dasd_device_process_ccw_queue(struct dasd_device *device,
1142 struct list_head *final_queue)
1144 struct list_head *l, *n;
1145 struct dasd_ccw_req *cqr;
1147 /* Process request with final status. */
1148 list_for_each_safe(l, n, &device->ccw_queue) {
1149 cqr = list_entry(l, struct dasd_ccw_req, devlist);
1151 /* Stop list processing at the first non-final request. */
1152 if (cqr->status == DASD_CQR_QUEUED ||
1153 cqr->status == DASD_CQR_IN_IO ||
1154 cqr->status == DASD_CQR_CLEAR_PENDING)
1156 if (cqr->status == DASD_CQR_ERROR) {
1157 __dasd_device_recovery(device, cqr);
1159 /* Rechain finished requests to final queue */
1160 list_move_tail(&cqr->devlist, final_queue);
1165 * the cqrs from the final queue are returned to the upper layer
1166 * by setting a dasd_block state and calling the callback function
1168 static void __dasd_device_process_final_queue(struct dasd_device *device,
1169 struct list_head *final_queue)
1171 struct list_head *l, *n;
1172 struct dasd_ccw_req *cqr;
1173 struct dasd_block *block;
1174 void (*callback)(struct dasd_ccw_req *, void *data);
1175 void *callback_data;
1177 list_for_each_safe(l, n, final_queue) {
1178 cqr = list_entry(l, struct dasd_ccw_req, devlist);
1179 list_del_init(&cqr->devlist);
1181 callback = cqr->callback;
1182 callback_data = cqr->callback_data;
1184 spin_lock_bh(&block->queue_lock);
1185 switch (cqr->status) {
1186 case DASD_CQR_SUCCESS:
1187 cqr->status = DASD_CQR_DONE;
1189 case DASD_CQR_ERROR:
1190 cqr->status = DASD_CQR_NEED_ERP;
1192 case DASD_CQR_CLEARED:
1193 cqr->status = DASD_CQR_TERMINATED;
1196 DEV_MESSAGE(KERN_ERR, device,
1197 "wrong cqr status in __dasd_process_final_queue "
1198 "for cqr %p, status %x",
1202 if (cqr->callback != NULL)
1203 (callback)(cqr, callback_data);
1205 spin_unlock_bh(&block->queue_lock);
1210 * Take a look at the first request on the ccw queue and check
1211 * if it reached its expire time. If so, terminate the IO.
1213 static void __dasd_device_check_expire(struct dasd_device *device)
1215 struct dasd_ccw_req *cqr;
1217 if (list_empty(&device->ccw_queue))
1219 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist);
1220 if ((cqr->status == DASD_CQR_IN_IO && cqr->expires != 0) &&
1221 (time_after_eq(jiffies, cqr->expires + cqr->starttime))) {
1222 if (device->discipline->term_IO(cqr) != 0) {
1223 /* Hmpf, try again in 5 sec */
1224 DEV_MESSAGE(KERN_ERR, device,
1225 "internal error - timeout (%is) expired "
1226 "for cqr %p, termination failed, "
1228 (cqr->expires/HZ), cqr);
1229 cqr->expires += 5*HZ;
1230 dasd_device_set_timer(device, 5*HZ);
1232 DEV_MESSAGE(KERN_ERR, device,
1233 "internal error - timeout (%is) expired "
1234 "for cqr %p (%i retries left)",
1235 (cqr->expires/HZ), cqr, cqr->retries);
1241 * Take a look at the first request on the ccw queue and check
1242 * if it needs to be started.
1244 static void __dasd_device_start_head(struct dasd_device *device)
1246 struct dasd_ccw_req *cqr;
1249 if (list_empty(&device->ccw_queue))
1251 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist);
1252 if (cqr->status != DASD_CQR_QUEUED)
1254 /* when device is stopped, return request to previous layer */
1255 if (device->stopped) {
1256 cqr->status = DASD_CQR_CLEARED;
1257 dasd_schedule_device_bh(device);
1261 rc = device->discipline->start_IO(cqr);
1263 dasd_device_set_timer(device, cqr->expires);
1264 else if (rc == -EACCES) {
1265 dasd_schedule_device_bh(device);
1267 /* Hmpf, try again in 1/2 sec */
1268 dasd_device_set_timer(device, 50);
1272 * Go through all request on the dasd_device request queue,
1273 * terminate them on the cdev if necessary, and return them to the
1274 * submitting layer via callback.
1276 * Make sure that all 'submitting layers' still exist when
1277 * this function is called!. In other words, when 'device' is a base
1278 * device then all block layer requests must have been removed before
1279 * via dasd_flush_block_queue.
1281 int dasd_flush_device_queue(struct dasd_device *device)
1283 struct dasd_ccw_req *cqr, *n;
1285 struct list_head flush_queue;
1287 INIT_LIST_HEAD(&flush_queue);
1288 spin_lock_irq(get_ccwdev_lock(device->cdev));
1290 list_for_each_entry_safe(cqr, n, &device->ccw_queue, devlist) {
1291 /* Check status and move request to flush_queue */
1292 switch (cqr->status) {
1293 case DASD_CQR_IN_IO:
1294 rc = device->discipline->term_IO(cqr);
1296 /* unable to terminate requeust */
1297 DEV_MESSAGE(KERN_ERR, device,
1298 "dasd flush ccw_queue is unable "
1299 " to terminate request %p",
1301 /* stop flush processing */
1305 case DASD_CQR_QUEUED:
1306 cqr->stopclk = get_clock();
1307 cqr->status = DASD_CQR_CLEARED;
1309 default: /* no need to modify the others */
1312 list_move_tail(&cqr->devlist, &flush_queue);
1315 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1317 * After this point all requests must be in state CLEAR_PENDING,
1318 * CLEARED, SUCCESS or ERROR. Now wait for CLEAR_PENDING to become
1319 * one of the others.
1321 list_for_each_entry_safe(cqr, n, &flush_queue, devlist)
1322 wait_event(dasd_flush_wq,
1323 (cqr->status != DASD_CQR_CLEAR_PENDING));
1325 * Now set each request back to TERMINATED, DONE or NEED_ERP
1326 * and call the callback function of flushed requests
1328 __dasd_device_process_final_queue(device, &flush_queue);
1333 * Acquire the device lock and process queues for the device.
1335 static void dasd_device_tasklet(struct dasd_device *device)
1337 struct list_head final_queue;
1339 atomic_set (&device->tasklet_scheduled, 0);
1340 INIT_LIST_HEAD(&final_queue);
1341 spin_lock_irq(get_ccwdev_lock(device->cdev));
1342 /* Check expire time of first request on the ccw queue. */
1343 __dasd_device_check_expire(device);
1344 /* find final requests on ccw queue */
1345 __dasd_device_process_ccw_queue(device, &final_queue);
1346 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1347 /* Now call the callback function of requests with final status */
1348 __dasd_device_process_final_queue(device, &final_queue);
1349 spin_lock_irq(get_ccwdev_lock(device->cdev));
1350 /* Now check if the head of the ccw queue needs to be started. */
1351 __dasd_device_start_head(device);
1352 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1353 dasd_put_device(device);
1357 * Schedules a call to dasd_tasklet over the device tasklet.
1359 void dasd_schedule_device_bh(struct dasd_device *device)
1361 /* Protect against rescheduling. */
1362 if (atomic_cmpxchg (&device->tasklet_scheduled, 0, 1) != 0)
1364 dasd_get_device(device);
1365 tasklet_hi_schedule(&device->tasklet);
1369 * Queue a request to the head of the device ccw_queue.
1370 * Start the I/O if possible.
1372 void dasd_add_request_head(struct dasd_ccw_req *cqr)
1374 struct dasd_device *device;
1375 unsigned long flags;
1377 device = cqr->startdev;
1378 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
1379 cqr->status = DASD_CQR_QUEUED;
1380 list_add(&cqr->devlist, &device->ccw_queue);
1381 /* let the bh start the request to keep them in order */
1382 dasd_schedule_device_bh(device);
1383 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
1387 * Queue a request to the tail of the device ccw_queue.
1388 * Start the I/O if possible.
1390 void dasd_add_request_tail(struct dasd_ccw_req *cqr)
1392 struct dasd_device *device;
1393 unsigned long flags;
1395 device = cqr->startdev;
1396 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
1397 cqr->status = DASD_CQR_QUEUED;
1398 list_add_tail(&cqr->devlist, &device->ccw_queue);
1399 /* let the bh start the request to keep them in order */
1400 dasd_schedule_device_bh(device);
1401 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
1405 * Wakeup helper for the 'sleep_on' functions.
1407 static void dasd_wakeup_cb(struct dasd_ccw_req *cqr, void *data)
1409 wake_up((wait_queue_head_t *) data);
1412 static inline int _wait_for_wakeup(struct dasd_ccw_req *cqr)
1414 struct dasd_device *device;
1417 device = cqr->startdev;
1418 spin_lock_irq(get_ccwdev_lock(device->cdev));
1419 rc = ((cqr->status == DASD_CQR_DONE ||
1420 cqr->status == DASD_CQR_NEED_ERP ||
1421 cqr->status == DASD_CQR_TERMINATED) &&
1422 list_empty(&cqr->devlist));
1423 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1428 * Queue a request to the tail of the device ccw_queue and wait for
1431 int dasd_sleep_on(struct dasd_ccw_req *cqr)
1433 struct dasd_device *device;
1436 device = cqr->startdev;
1438 cqr->callback = dasd_wakeup_cb;
1439 cqr->callback_data = (void *) &generic_waitq;
1440 dasd_add_request_tail(cqr);
1441 wait_event(generic_waitq, _wait_for_wakeup(cqr));
1443 /* Request status is either done or failed. */
1444 rc = (cqr->status == DASD_CQR_DONE) ? 0 : -EIO;
1449 * Queue a request to the tail of the device ccw_queue and wait
1450 * interruptible for it's completion.
1452 int dasd_sleep_on_interruptible(struct dasd_ccw_req *cqr)
1454 struct dasd_device *device;
1457 device = cqr->startdev;
1458 cqr->callback = dasd_wakeup_cb;
1459 cqr->callback_data = (void *) &generic_waitq;
1460 dasd_add_request_tail(cqr);
1461 rc = wait_event_interruptible(generic_waitq, _wait_for_wakeup(cqr));
1462 if (rc == -ERESTARTSYS) {
1463 dasd_cancel_req(cqr);
1464 /* wait (non-interruptible) for final status */
1465 wait_event(generic_waitq, _wait_for_wakeup(cqr));
1467 rc = (cqr->status == DASD_CQR_DONE) ? 0 : -EIO;
1472 * Whoa nelly now it gets really hairy. For some functions (e.g. steal lock
1473 * for eckd devices) the currently running request has to be terminated
1474 * and be put back to status queued, before the special request is added
1475 * to the head of the queue. Then the special request is waited on normally.
1477 static inline int _dasd_term_running_cqr(struct dasd_device *device)
1479 struct dasd_ccw_req *cqr;
1481 if (list_empty(&device->ccw_queue))
1483 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist);
1484 return device->discipline->term_IO(cqr);
1487 int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr)
1489 struct dasd_device *device;
1492 device = cqr->startdev;
1493 spin_lock_irq(get_ccwdev_lock(device->cdev));
1494 rc = _dasd_term_running_cqr(device);
1496 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1500 cqr->callback = dasd_wakeup_cb;
1501 cqr->callback_data = (void *) &generic_waitq;
1502 cqr->status = DASD_CQR_QUEUED;
1503 list_add(&cqr->devlist, &device->ccw_queue);
1505 /* let the bh start the request to keep them in order */
1506 dasd_schedule_device_bh(device);
1508 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1510 wait_event(generic_waitq, _wait_for_wakeup(cqr));
1512 /* Request status is either done or failed. */
1513 rc = (cqr->status == DASD_CQR_DONE) ? 0 : -EIO;
1518 * Cancels a request that was started with dasd_sleep_on_req.
1519 * This is useful to timeout requests. The request will be
1520 * terminated if it is currently in i/o.
1521 * Returns 1 if the request has been terminated.
1522 * 0 if there was no need to terminate the request (not started yet)
1523 * negative error code if termination failed
1524 * Cancellation of a request is an asynchronous operation! The calling
1525 * function has to wait until the request is properly returned via callback.
1527 int dasd_cancel_req(struct dasd_ccw_req *cqr)
1529 struct dasd_device *device = cqr->startdev;
1530 unsigned long flags;
1534 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
1535 switch (cqr->status) {
1536 case DASD_CQR_QUEUED:
1537 /* request was not started - just set to cleared */
1538 cqr->status = DASD_CQR_CLEARED;
1540 case DASD_CQR_IN_IO:
1541 /* request in IO - terminate IO and release again */
1542 rc = device->discipline->term_IO(cqr);
1544 DEV_MESSAGE(KERN_ERR, device,
1545 "dasd_cancel_req is unable "
1546 " to terminate request %p, rc = %d",
1549 cqr->stopclk = get_clock();
1553 default: /* already finished or clear pending - do nothing */
1556 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
1557 dasd_schedule_device_bh(device);
1563 * SECTION: Operations of the dasd_block layer.
1567 * Timeout function for dasd_block. This is used when the block layer
1568 * is waiting for something that may not come reliably, (e.g. a state
1571 static void dasd_block_timeout(unsigned long ptr)
1573 unsigned long flags;
1574 struct dasd_block *block;
1576 block = (struct dasd_block *) ptr;
1577 spin_lock_irqsave(get_ccwdev_lock(block->base->cdev), flags);
1578 /* re-activate request queue */
1579 block->base->stopped &= ~DASD_STOPPED_PENDING;
1580 spin_unlock_irqrestore(get_ccwdev_lock(block->base->cdev), flags);
1581 dasd_schedule_block_bh(block);
1585 * Setup timeout for a dasd_block in jiffies.
1587 void dasd_block_set_timer(struct dasd_block *block, int expires)
1590 if (timer_pending(&block->timer))
1591 del_timer(&block->timer);
1594 if (timer_pending(&block->timer)) {
1595 if (mod_timer(&block->timer, jiffies + expires))
1598 block->timer.function = dasd_block_timeout;
1599 block->timer.data = (unsigned long) block;
1600 block->timer.expires = jiffies + expires;
1601 add_timer(&block->timer);
1605 * Clear timeout for a dasd_block.
1607 void dasd_block_clear_timer(struct dasd_block *block)
1609 if (timer_pending(&block->timer))
1610 del_timer(&block->timer);
1614 * posts the buffer_cache about a finalized request
1616 static inline void dasd_end_request(struct request *req, int error)
1618 if (__blk_end_request(req, error, blk_rq_bytes(req)))
1623 * Process finished error recovery ccw.
1625 static inline void __dasd_block_process_erp(struct dasd_block *block,
1626 struct dasd_ccw_req *cqr)
1628 dasd_erp_fn_t erp_fn;
1629 struct dasd_device *device = block->base;
1631 if (cqr->status == DASD_CQR_DONE)
1632 DBF_DEV_EVENT(DBF_NOTICE, device, "%s", "ERP successful");
1634 DEV_MESSAGE(KERN_ERR, device, "%s", "ERP unsuccessful");
1635 erp_fn = device->discipline->erp_postaction(cqr);
1640 * Fetch requests from the block device queue.
1642 static void __dasd_process_request_queue(struct dasd_block *block)
1644 struct request_queue *queue;
1645 struct request *req;
1646 struct dasd_ccw_req *cqr;
1647 struct dasd_device *basedev;
1648 unsigned long flags;
1649 queue = block->request_queue;
1650 basedev = block->base;
1651 /* No queue ? Then there is nothing to do. */
1656 * We requeue request from the block device queue to the ccw
1657 * queue only in two states. In state DASD_STATE_READY the
1658 * partition detection is done and we need to requeue requests
1659 * for that. State DASD_STATE_ONLINE is normal block device
1662 if (basedev->state < DASD_STATE_READY)
1664 /* Now we try to fetch requests from the request queue */
1665 while (!blk_queue_plugged(queue) &&
1666 elv_next_request(queue)) {
1668 req = elv_next_request(queue);
1670 if (basedev->features & DASD_FEATURE_READONLY &&
1671 rq_data_dir(req) == WRITE) {
1672 DBF_DEV_EVENT(DBF_ERR, basedev,
1673 "Rejecting write request %p",
1675 blkdev_dequeue_request(req);
1676 dasd_end_request(req, -EIO);
1679 cqr = basedev->discipline->build_cp(basedev, block, req);
1681 if (PTR_ERR(cqr) == -EBUSY)
1682 break; /* normal end condition */
1683 if (PTR_ERR(cqr) == -ENOMEM)
1684 break; /* terminate request queue loop */
1685 if (PTR_ERR(cqr) == -EAGAIN) {
1687 * The current request cannot be build right
1688 * now, we have to try later. If this request
1689 * is the head-of-queue we stop the device
1692 if (!list_empty(&block->ccw_queue))
1694 spin_lock_irqsave(get_ccwdev_lock(basedev->cdev), flags);
1695 basedev->stopped |= DASD_STOPPED_PENDING;
1696 spin_unlock_irqrestore(get_ccwdev_lock(basedev->cdev), flags);
1697 dasd_block_set_timer(block, HZ/2);
1700 DBF_DEV_EVENT(DBF_ERR, basedev,
1701 "CCW creation failed (rc=%ld) "
1704 blkdev_dequeue_request(req);
1705 dasd_end_request(req, -EIO);
1709 * Note: callback is set to dasd_return_cqr_cb in
1710 * __dasd_block_start_head to cover erp requests as well
1712 cqr->callback_data = (void *) req;
1713 cqr->status = DASD_CQR_FILLED;
1714 blkdev_dequeue_request(req);
1715 list_add_tail(&cqr->blocklist, &block->ccw_queue);
1716 dasd_profile_start(block, cqr, req);
1720 static void __dasd_cleanup_cqr(struct dasd_ccw_req *cqr)
1722 struct request *req;
1726 req = (struct request *) cqr->callback_data;
1727 dasd_profile_end(cqr->block, cqr, req);
1728 status = cqr->block->base->discipline->free_cp(cqr, req);
1730 error = status ? status : -EIO;
1731 dasd_end_request(req, error);
1735 * Process ccw request queue.
1737 static void __dasd_process_block_ccw_queue(struct dasd_block *block,
1738 struct list_head *final_queue)
1740 struct list_head *l, *n;
1741 struct dasd_ccw_req *cqr;
1742 dasd_erp_fn_t erp_fn;
1743 unsigned long flags;
1744 struct dasd_device *base = block->base;
1747 /* Process request with final status. */
1748 list_for_each_safe(l, n, &block->ccw_queue) {
1749 cqr = list_entry(l, struct dasd_ccw_req, blocklist);
1750 if (cqr->status != DASD_CQR_DONE &&
1751 cqr->status != DASD_CQR_FAILED &&
1752 cqr->status != DASD_CQR_NEED_ERP &&
1753 cqr->status != DASD_CQR_TERMINATED)
1756 if (cqr->status == DASD_CQR_TERMINATED) {
1757 base->discipline->handle_terminated_request(cqr);
1761 /* Process requests that may be recovered */
1762 if (cqr->status == DASD_CQR_NEED_ERP) {
1763 erp_fn = base->discipline->erp_action(cqr);
1768 /* log sense for fatal error */
1769 if (cqr->status == DASD_CQR_FAILED) {
1770 dasd_log_sense(cqr, &cqr->irb);
1773 /* First of all call extended error reporting. */
1774 if (dasd_eer_enabled(base) &&
1775 cqr->status == DASD_CQR_FAILED) {
1776 dasd_eer_write(base, cqr, DASD_EER_FATALERROR);
1778 /* restart request */
1779 cqr->status = DASD_CQR_FILLED;
1781 spin_lock_irqsave(get_ccwdev_lock(base->cdev), flags);
1782 base->stopped |= DASD_STOPPED_QUIESCE;
1783 spin_unlock_irqrestore(get_ccwdev_lock(base->cdev),
1788 /* Process finished ERP request. */
1790 __dasd_block_process_erp(block, cqr);
1794 /* Rechain finished requests to final queue */
1795 cqr->endclk = get_clock();
1796 list_move_tail(&cqr->blocklist, final_queue);
1800 static void dasd_return_cqr_cb(struct dasd_ccw_req *cqr, void *data)
1802 dasd_schedule_block_bh(cqr->block);
1805 static void __dasd_block_start_head(struct dasd_block *block)
1807 struct dasd_ccw_req *cqr;
1809 if (list_empty(&block->ccw_queue))
1811 /* We allways begin with the first requests on the queue, as some
1812 * of previously started requests have to be enqueued on a
1813 * dasd_device again for error recovery.
1815 list_for_each_entry(cqr, &block->ccw_queue, blocklist) {
1816 if (cqr->status != DASD_CQR_FILLED)
1818 /* Non-temporary stop condition will trigger fail fast */
1819 if (block->base->stopped & ~DASD_STOPPED_PENDING &&
1820 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) &&
1821 (!dasd_eer_enabled(block->base))) {
1822 cqr->status = DASD_CQR_FAILED;
1823 dasd_schedule_block_bh(block);
1826 /* Don't try to start requests if device is stopped */
1827 if (block->base->stopped)
1830 /* just a fail safe check, should not happen */
1832 cqr->startdev = block->base;
1834 /* make sure that the requests we submit find their way back */
1835 cqr->callback = dasd_return_cqr_cb;
1837 dasd_add_request_tail(cqr);
1842 * Central dasd_block layer routine. Takes requests from the generic
1843 * block layer request queue, creates ccw requests, enqueues them on
1844 * a dasd_device and processes ccw requests that have been returned.
1846 static void dasd_block_tasklet(struct dasd_block *block)
1848 struct list_head final_queue;
1849 struct list_head *l, *n;
1850 struct dasd_ccw_req *cqr;
1852 atomic_set(&block->tasklet_scheduled, 0);
1853 INIT_LIST_HEAD(&final_queue);
1854 spin_lock(&block->queue_lock);
1855 /* Finish off requests on ccw queue */
1856 __dasd_process_block_ccw_queue(block, &final_queue);
1857 spin_unlock(&block->queue_lock);
1858 /* Now call the callback function of requests with final status */
1859 spin_lock_irq(&block->request_queue_lock);
1860 list_for_each_safe(l, n, &final_queue) {
1861 cqr = list_entry(l, struct dasd_ccw_req, blocklist);
1862 list_del_init(&cqr->blocklist);
1863 __dasd_cleanup_cqr(cqr);
1865 spin_lock(&block->queue_lock);
1866 /* Get new request from the block device request queue */
1867 __dasd_process_request_queue(block);
1868 /* Now check if the head of the ccw queue needs to be started. */
1869 __dasd_block_start_head(block);
1870 spin_unlock(&block->queue_lock);
1871 spin_unlock_irq(&block->request_queue_lock);
1872 dasd_put_device(block->base);
1875 static void _dasd_wake_block_flush_cb(struct dasd_ccw_req *cqr, void *data)
1877 wake_up(&dasd_flush_wq);
1881 * Go through all request on the dasd_block request queue, cancel them
1882 * on the respective dasd_device, and return them to the generic
1885 static int dasd_flush_block_queue(struct dasd_block *block)
1887 struct dasd_ccw_req *cqr, *n;
1889 struct list_head flush_queue;
1891 INIT_LIST_HEAD(&flush_queue);
1892 spin_lock_bh(&block->queue_lock);
1895 list_for_each_entry_safe(cqr, n, &block->ccw_queue, blocklist) {
1896 /* if this request currently owned by a dasd_device cancel it */
1897 if (cqr->status >= DASD_CQR_QUEUED)
1898 rc = dasd_cancel_req(cqr);
1901 /* Rechain request (including erp chain) so it won't be
1902 * touched by the dasd_block_tasklet anymore.
1903 * Replace the callback so we notice when the request
1904 * is returned from the dasd_device layer.
1906 cqr->callback = _dasd_wake_block_flush_cb;
1907 for (i = 0; cqr != NULL; cqr = cqr->refers, i++)
1908 list_move_tail(&cqr->blocklist, &flush_queue);
1910 /* moved more than one request - need to restart */
1913 spin_unlock_bh(&block->queue_lock);
1914 /* Now call the callback function of flushed requests */
1916 list_for_each_entry_safe(cqr, n, &flush_queue, blocklist) {
1917 wait_event(dasd_flush_wq, (cqr->status < DASD_CQR_QUEUED));
1918 /* Process finished ERP request. */
1920 spin_lock_bh(&block->queue_lock);
1921 __dasd_block_process_erp(block, cqr);
1922 spin_unlock_bh(&block->queue_lock);
1923 /* restart list_for_xx loop since dasd_process_erp
1924 * might remove multiple elements */
1927 /* call the callback function */
1928 spin_lock_irq(&block->request_queue_lock);
1929 cqr->endclk = get_clock();
1930 list_del_init(&cqr->blocklist);
1931 __dasd_cleanup_cqr(cqr);
1932 spin_unlock_irq(&block->request_queue_lock);
1938 * Schedules a call to dasd_tasklet over the device tasklet.
1940 void dasd_schedule_block_bh(struct dasd_block *block)
1942 /* Protect against rescheduling. */
1943 if (atomic_cmpxchg(&block->tasklet_scheduled, 0, 1) != 0)
1945 /* life cycle of block is bound to it's base device */
1946 dasd_get_device(block->base);
1947 tasklet_hi_schedule(&block->tasklet);
1952 * SECTION: external block device operations
1953 * (request queue handling, open, release, etc.)
1957 * Dasd request queue function. Called from ll_rw_blk.c
1959 static void do_dasd_request(struct request_queue *queue)
1961 struct dasd_block *block;
1963 block = queue->queuedata;
1964 spin_lock(&block->queue_lock);
1965 /* Get new request from the block device request queue */
1966 __dasd_process_request_queue(block);
1967 /* Now check if the head of the ccw queue needs to be started. */
1968 __dasd_block_start_head(block);
1969 spin_unlock(&block->queue_lock);
1973 * Allocate and initialize request queue and default I/O scheduler.
1975 static int dasd_alloc_queue(struct dasd_block *block)
1979 block->request_queue = blk_init_queue(do_dasd_request,
1980 &block->request_queue_lock);
1981 if (block->request_queue == NULL)
1984 block->request_queue->queuedata = block;
1986 elevator_exit(block->request_queue->elevator);
1987 block->request_queue->elevator = NULL;
1988 rc = elevator_init(block->request_queue, "deadline");
1990 blk_cleanup_queue(block->request_queue);
1997 * Allocate and initialize request queue.
1999 static void dasd_setup_queue(struct dasd_block *block)
2003 blk_queue_hardsect_size(block->request_queue, block->bp_block);
2004 max = block->base->discipline->max_blocks << block->s2b_shift;
2005 blk_queue_max_sectors(block->request_queue, max);
2006 blk_queue_max_phys_segments(block->request_queue, -1L);
2007 blk_queue_max_hw_segments(block->request_queue, -1L);
2008 blk_queue_max_segment_size(block->request_queue, -1L);
2009 blk_queue_segment_boundary(block->request_queue, -1L);
2010 blk_queue_ordered(block->request_queue, QUEUE_ORDERED_DRAIN, NULL);
2014 * Deactivate and free request queue.
2016 static void dasd_free_queue(struct dasd_block *block)
2018 if (block->request_queue) {
2019 blk_cleanup_queue(block->request_queue);
2020 block->request_queue = NULL;
2025 * Flush request on the request queue.
2027 static void dasd_flush_request_queue(struct dasd_block *block)
2029 struct request *req;
2031 if (!block->request_queue)
2034 spin_lock_irq(&block->request_queue_lock);
2035 while ((req = elv_next_request(block->request_queue))) {
2036 blkdev_dequeue_request(req);
2037 dasd_end_request(req, -EIO);
2039 spin_unlock_irq(&block->request_queue_lock);
2042 static int dasd_open(struct block_device *bdev, fmode_t mode)
2044 struct dasd_block *block = bdev->bd_disk->private_data;
2045 struct dasd_device *base = block->base;
2048 atomic_inc(&block->open_count);
2049 if (test_bit(DASD_FLAG_OFFLINE, &base->flags)) {
2054 if (!try_module_get(base->discipline->owner)) {
2059 if (dasd_probeonly) {
2060 DEV_MESSAGE(KERN_INFO, base, "%s",
2061 "No access to device due to probeonly mode");
2066 if (base->state <= DASD_STATE_BASIC) {
2067 DBF_DEV_EVENT(DBF_ERR, base, " %s",
2068 " Cannot open unrecognized device");
2076 module_put(base->discipline->owner);
2078 atomic_dec(&block->open_count);
2082 static int dasd_release(struct gendisk *disk, fmode_t mode)
2084 struct dasd_block *block = disk->private_data;
2086 atomic_dec(&block->open_count);
2087 module_put(block->base->discipline->owner);
2092 * Return disk geometry.
2094 static int dasd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
2096 struct dasd_block *block;
2097 struct dasd_device *base;
2099 block = bdev->bd_disk->private_data;
2104 if (!base->discipline ||
2105 !base->discipline->fill_geometry)
2108 base->discipline->fill_geometry(block, geo);
2109 geo->start = get_start_sect(bdev) >> block->s2b_shift;
2113 struct block_device_operations
2114 dasd_device_operations = {
2115 .owner = THIS_MODULE,
2117 .release = dasd_release,
2118 .locked_ioctl = dasd_ioctl,
2119 .getgeo = dasd_getgeo,
2122 /*******************************************************************************
2123 * end of block device operations
2129 #ifdef CONFIG_PROC_FS
2133 if (dasd_page_cache != NULL) {
2134 kmem_cache_destroy(dasd_page_cache);
2135 dasd_page_cache = NULL;
2137 dasd_gendisk_exit();
2139 if (dasd_debug_area != NULL) {
2140 debug_unregister(dasd_debug_area);
2141 dasd_debug_area = NULL;
2146 * SECTION: common functions for ccw_driver use
2150 * Initial attempt at a probe function. this can be simplified once
2151 * the other detection code is gone.
2153 int dasd_generic_probe(struct ccw_device *cdev,
2154 struct dasd_discipline *discipline)
2158 ret = ccw_device_set_options(cdev, CCWDEV_DO_PATHGROUP);
2161 "dasd_generic_probe: could not set ccw-device options "
2162 "for %s\n", dev_name(&cdev->dev));
2165 ret = dasd_add_sysfs_files(cdev);
2168 "dasd_generic_probe: could not add sysfs entries "
2169 "for %s\n", dev_name(&cdev->dev));
2172 cdev->handler = &dasd_int_handler;
2175 * Automatically online either all dasd devices (dasd_autodetect)
2176 * or all devices specified with dasd= parameters during
2179 if ((dasd_get_feature(cdev, DASD_FEATURE_INITIAL_ONLINE) > 0 ) ||
2180 (dasd_autodetect && dasd_busid_known(dev_name(&cdev->dev)) != 0))
2181 ret = ccw_device_set_online(cdev);
2184 "dasd_generic_probe: could not initially "
2185 "online ccw-device %s; return code: %d\n",
2186 dev_name(&cdev->dev), ret);
2191 * This will one day be called from a global not_oper handler.
2192 * It is also used by driver_unregister during module unload.
2194 void dasd_generic_remove(struct ccw_device *cdev)
2196 struct dasd_device *device;
2197 struct dasd_block *block;
2199 cdev->handler = NULL;
2201 dasd_remove_sysfs_files(cdev);
2202 device = dasd_device_from_cdev(cdev);
2205 if (test_and_set_bit(DASD_FLAG_OFFLINE, &device->flags)) {
2206 /* Already doing offline processing */
2207 dasd_put_device(device);
2211 * This device is removed unconditionally. Set offline
2212 * flag to prevent dasd_open from opening it while it is
2213 * no quite down yet.
2215 dasd_set_target_state(device, DASD_STATE_NEW);
2216 /* dasd_delete_device destroys the device reference. */
2217 block = device->block;
2218 device->block = NULL;
2219 dasd_delete_device(device);
2221 * life cycle of block is bound to device, so delete it after
2222 * device was safely removed
2225 dasd_free_block(block);
2229 * Activate a device. This is called from dasd_{eckd,fba}_probe() when either
2230 * the device is detected for the first time and is supposed to be used
2231 * or the user has started activation through sysfs.
2233 int dasd_generic_set_online(struct ccw_device *cdev,
2234 struct dasd_discipline *base_discipline)
2236 struct dasd_discipline *discipline;
2237 struct dasd_device *device;
2240 /* first online clears initial online feature flag */
2241 dasd_set_feature(cdev, DASD_FEATURE_INITIAL_ONLINE, 0);
2242 device = dasd_create_device(cdev);
2244 return PTR_ERR(device);
2246 discipline = base_discipline;
2247 if (device->features & DASD_FEATURE_USEDIAG) {
2248 if (!dasd_diag_discipline_pointer) {
2249 printk (KERN_WARNING
2250 "dasd_generic couldn't online device %s "
2251 "- discipline DIAG not available\n",
2252 dev_name(&cdev->dev));
2253 dasd_delete_device(device);
2256 discipline = dasd_diag_discipline_pointer;
2258 if (!try_module_get(base_discipline->owner)) {
2259 dasd_delete_device(device);
2262 if (!try_module_get(discipline->owner)) {
2263 module_put(base_discipline->owner);
2264 dasd_delete_device(device);
2267 device->base_discipline = base_discipline;
2268 device->discipline = discipline;
2270 /* check_device will allocate block device if necessary */
2271 rc = discipline->check_device(device);
2273 printk (KERN_WARNING
2274 "dasd_generic couldn't online device %s "
2275 "with discipline %s rc=%i\n",
2276 dev_name(&cdev->dev), discipline->name, rc);
2277 module_put(discipline->owner);
2278 module_put(base_discipline->owner);
2279 dasd_delete_device(device);
2283 dasd_set_target_state(device, DASD_STATE_ONLINE);
2284 if (device->state <= DASD_STATE_KNOWN) {
2285 printk (KERN_WARNING
2286 "dasd_generic discipline not found for %s\n",
2287 dev_name(&cdev->dev));
2289 dasd_set_target_state(device, DASD_STATE_NEW);
2291 dasd_free_block(device->block);
2292 dasd_delete_device(device);
2294 pr_debug("dasd_generic device %s found\n",
2295 dev_name(&cdev->dev));
2297 /* FIXME: we have to wait for the root device but we don't want
2298 * to wait for each single device but for all at once. */
2299 wait_event(dasd_init_waitq, _wait_for_device(device));
2301 dasd_put_device(device);
2306 int dasd_generic_set_offline(struct ccw_device *cdev)
2308 struct dasd_device *device;
2309 struct dasd_block *block;
2310 int max_count, open_count;
2312 device = dasd_device_from_cdev(cdev);
2314 return PTR_ERR(device);
2315 if (test_and_set_bit(DASD_FLAG_OFFLINE, &device->flags)) {
2316 /* Already doing offline processing */
2317 dasd_put_device(device);
2321 * We must make sure that this device is currently not in use.
2322 * The open_count is increased for every opener, that includes
2323 * the blkdev_get in dasd_scan_partitions. We are only interested
2324 * in the other openers.
2326 if (device->block) {
2327 max_count = device->block->bdev ? 0 : -1;
2328 open_count = atomic_read(&device->block->open_count);
2329 if (open_count > max_count) {
2331 printk(KERN_WARNING "Can't offline dasd "
2332 "device with open count = %i.\n",
2335 printk(KERN_WARNING "%s",
2336 "Can't offline dasd device due "
2337 "to internal use\n");
2338 clear_bit(DASD_FLAG_OFFLINE, &device->flags);
2339 dasd_put_device(device);
2343 dasd_set_target_state(device, DASD_STATE_NEW);
2344 /* dasd_delete_device destroys the device reference. */
2345 block = device->block;
2346 device->block = NULL;
2347 dasd_delete_device(device);
2349 * life cycle of block is bound to device, so delete it after
2350 * device was safely removed
2353 dasd_free_block(block);
2357 int dasd_generic_notify(struct ccw_device *cdev, int event)
2359 struct dasd_device *device;
2360 struct dasd_ccw_req *cqr;
2363 device = dasd_device_from_cdev_locked(cdev);
2370 /* First of all call extended error reporting. */
2371 dasd_eer_write(device, NULL, DASD_EER_NOPATH);
2373 if (device->state < DASD_STATE_BASIC)
2375 /* Device is active. We want to keep it. */
2376 list_for_each_entry(cqr, &device->ccw_queue, devlist)
2377 if (cqr->status == DASD_CQR_IN_IO) {
2378 cqr->status = DASD_CQR_QUEUED;
2381 device->stopped |= DASD_STOPPED_DC_WAIT;
2382 dasd_device_clear_timer(device);
2383 dasd_schedule_device_bh(device);
2387 /* FIXME: add a sanity check. */
2388 device->stopped &= ~DASD_STOPPED_DC_WAIT;
2389 dasd_schedule_device_bh(device);
2391 dasd_schedule_block_bh(device->block);
2395 dasd_put_device(device);
2399 static struct dasd_ccw_req *dasd_generic_build_rdc(struct dasd_device *device,
2401 int rdc_buffer_size,
2404 struct dasd_ccw_req *cqr;
2407 cqr = dasd_smalloc_request(magic, 1 /* RDC */, rdc_buffer_size, device);
2410 DEV_MESSAGE(KERN_WARNING, device, "%s",
2411 "Could not allocate RDC request");
2416 ccw->cmd_code = CCW_CMD_RDC;
2417 ccw->cda = (__u32)(addr_t)rdc_buffer;
2418 ccw->count = rdc_buffer_size;
2420 cqr->startdev = device;
2421 cqr->memdev = device;
2422 cqr->expires = 10*HZ;
2423 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
2425 cqr->buildclk = get_clock();
2426 cqr->status = DASD_CQR_FILLED;
2431 int dasd_generic_read_dev_chars(struct dasd_device *device, char *magic,
2432 void **rdc_buffer, int rdc_buffer_size)
2435 struct dasd_ccw_req *cqr;
2437 cqr = dasd_generic_build_rdc(device, *rdc_buffer, rdc_buffer_size,
2440 return PTR_ERR(cqr);
2442 ret = dasd_sleep_on(cqr);
2443 dasd_sfree_request(cqr, cqr->memdev);
2446 EXPORT_SYMBOL_GPL(dasd_generic_read_dev_chars);
2448 static int __init dasd_init(void)
2452 init_waitqueue_head(&dasd_init_waitq);
2453 init_waitqueue_head(&dasd_flush_wq);
2454 init_waitqueue_head(&generic_waitq);
2456 /* register 'common' DASD debug area, used for all DBF_XXX calls */
2457 dasd_debug_area = debug_register("dasd", 1, 1, 8 * sizeof(long));
2458 if (dasd_debug_area == NULL) {
2462 debug_register_view(dasd_debug_area, &debug_sprintf_view);
2463 debug_set_level(dasd_debug_area, DBF_WARNING);
2465 DBF_EVENT(DBF_EMERG, "%s", "debug area created");
2467 dasd_diag_discipline_pointer = NULL;
2469 rc = dasd_devmap_init();
2472 rc = dasd_gendisk_init();
2478 rc = dasd_eer_init();
2481 #ifdef CONFIG_PROC_FS
2482 rc = dasd_proc_init();
2489 MESSAGE(KERN_INFO, "%s", "initialization not performed due to errors");
2494 module_init(dasd_init);
2495 module_exit(dasd_exit);
2497 EXPORT_SYMBOL(dasd_debug_area);
2498 EXPORT_SYMBOL(dasd_diag_discipline_pointer);
2500 EXPORT_SYMBOL(dasd_add_request_head);
2501 EXPORT_SYMBOL(dasd_add_request_tail);
2502 EXPORT_SYMBOL(dasd_cancel_req);
2503 EXPORT_SYMBOL(dasd_device_clear_timer);
2504 EXPORT_SYMBOL(dasd_block_clear_timer);
2505 EXPORT_SYMBOL(dasd_enable_device);
2506 EXPORT_SYMBOL(dasd_int_handler);
2507 EXPORT_SYMBOL(dasd_kfree_request);
2508 EXPORT_SYMBOL(dasd_kick_device);
2509 EXPORT_SYMBOL(dasd_kmalloc_request);
2510 EXPORT_SYMBOL(dasd_schedule_device_bh);
2511 EXPORT_SYMBOL(dasd_schedule_block_bh);
2512 EXPORT_SYMBOL(dasd_set_target_state);
2513 EXPORT_SYMBOL(dasd_device_set_timer);
2514 EXPORT_SYMBOL(dasd_block_set_timer);
2515 EXPORT_SYMBOL(dasd_sfree_request);
2516 EXPORT_SYMBOL(dasd_sleep_on);
2517 EXPORT_SYMBOL(dasd_sleep_on_immediatly);
2518 EXPORT_SYMBOL(dasd_sleep_on_interruptible);
2519 EXPORT_SYMBOL(dasd_smalloc_request);
2520 EXPORT_SYMBOL(dasd_start_IO);
2521 EXPORT_SYMBOL(dasd_term_IO);
2523 EXPORT_SYMBOL_GPL(dasd_generic_probe);
2524 EXPORT_SYMBOL_GPL(dasd_generic_remove);
2525 EXPORT_SYMBOL_GPL(dasd_generic_notify);
2526 EXPORT_SYMBOL_GPL(dasd_generic_set_online);
2527 EXPORT_SYMBOL_GPL(dasd_generic_set_offline);
2528 EXPORT_SYMBOL_GPL(dasd_generic_handle_state_change);
2529 EXPORT_SYMBOL_GPL(dasd_flush_device_queue);
2530 EXPORT_SYMBOL_GPL(dasd_alloc_block);
2531 EXPORT_SYMBOL_GPL(dasd_free_block);