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 #define KMSG_COMPONENT "dasd"
13 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
15 #include <linux/kmod.h>
16 #include <linux/init.h>
17 #include <linux/interrupt.h>
18 #include <linux/ctype.h>
19 #include <linux/major.h>
20 #include <linux/slab.h>
21 #include <linux/buffer_head.h>
22 #include <linux/hdreg.h>
24 #include <asm/ccwdev.h>
25 #include <asm/ebcdic.h>
26 #include <asm/idals.h>
27 #include <asm/todclk.h>
31 #define PRINTK_HEADER "dasd:"
35 * SECTION: Constant definitions to be used within this file
37 #define DASD_CHANQ_MAX_SIZE 4
40 * SECTION: exported variables of dasd.c
42 debug_info_t *dasd_debug_area;
43 struct dasd_discipline *dasd_diag_discipline_pointer;
44 void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *);
46 MODULE_AUTHOR("Holger Smolinski <Holger.Smolinski@de.ibm.com>");
47 MODULE_DESCRIPTION("Linux on S/390 DASD device driver,"
48 " Copyright 2000 IBM Corporation");
49 MODULE_SUPPORTED_DEVICE("dasd");
50 MODULE_LICENSE("GPL");
53 * SECTION: prototypes for static functions of dasd.c
55 static int dasd_alloc_queue(struct dasd_block *);
56 static void dasd_setup_queue(struct dasd_block *);
57 static void dasd_free_queue(struct dasd_block *);
58 static void dasd_flush_request_queue(struct dasd_block *);
59 static int dasd_flush_block_queue(struct dasd_block *);
60 static void dasd_device_tasklet(struct dasd_device *);
61 static void dasd_block_tasklet(struct dasd_block *);
62 static void do_kick_device(struct work_struct *);
63 static void dasd_return_cqr_cb(struct dasd_ccw_req *, void *);
64 static void dasd_device_timeout(unsigned long);
65 static void dasd_block_timeout(unsigned long);
68 * SECTION: Operations on the device structure.
70 static wait_queue_head_t dasd_init_waitq;
71 static wait_queue_head_t dasd_flush_wq;
72 static wait_queue_head_t generic_waitq;
75 * Allocate memory for a new device structure.
77 struct dasd_device *dasd_alloc_device(void)
79 struct dasd_device *device;
81 device = kzalloc(sizeof(struct dasd_device), GFP_ATOMIC);
83 return ERR_PTR(-ENOMEM);
85 /* Get two pages for normal block device operations. */
86 device->ccw_mem = (void *) __get_free_pages(GFP_ATOMIC | GFP_DMA, 1);
87 if (!device->ccw_mem) {
89 return ERR_PTR(-ENOMEM);
91 /* Get one page for error recovery. */
92 device->erp_mem = (void *) get_zeroed_page(GFP_ATOMIC | GFP_DMA);
93 if (!device->erp_mem) {
94 free_pages((unsigned long) device->ccw_mem, 1);
96 return ERR_PTR(-ENOMEM);
99 dasd_init_chunklist(&device->ccw_chunks, device->ccw_mem, PAGE_SIZE*2);
100 dasd_init_chunklist(&device->erp_chunks, device->erp_mem, PAGE_SIZE);
101 spin_lock_init(&device->mem_lock);
102 atomic_set(&device->tasklet_scheduled, 0);
103 tasklet_init(&device->tasklet,
104 (void (*)(unsigned long)) dasd_device_tasklet,
105 (unsigned long) device);
106 INIT_LIST_HEAD(&device->ccw_queue);
107 init_timer(&device->timer);
108 device->timer.function = dasd_device_timeout;
109 device->timer.data = (unsigned long) device;
110 INIT_WORK(&device->kick_work, do_kick_device);
111 device->state = DASD_STATE_NEW;
112 device->target = DASD_STATE_NEW;
118 * Free memory of a device structure.
120 void dasd_free_device(struct dasd_device *device)
122 kfree(device->private);
123 free_page((unsigned long) device->erp_mem);
124 free_pages((unsigned long) device->ccw_mem, 1);
129 * Allocate memory for a new device structure.
131 struct dasd_block *dasd_alloc_block(void)
133 struct dasd_block *block;
135 block = kzalloc(sizeof(*block), GFP_ATOMIC);
137 return ERR_PTR(-ENOMEM);
138 /* open_count = 0 means device online but not in use */
139 atomic_set(&block->open_count, -1);
141 spin_lock_init(&block->request_queue_lock);
142 atomic_set(&block->tasklet_scheduled, 0);
143 tasklet_init(&block->tasklet,
144 (void (*)(unsigned long)) dasd_block_tasklet,
145 (unsigned long) block);
146 INIT_LIST_HEAD(&block->ccw_queue);
147 spin_lock_init(&block->queue_lock);
148 init_timer(&block->timer);
149 block->timer.function = dasd_block_timeout;
150 block->timer.data = (unsigned long) block;
156 * Free memory of a device structure.
158 void dasd_free_block(struct dasd_block *block)
164 * Make a new device known to the system.
166 static int dasd_state_new_to_known(struct dasd_device *device)
171 * As long as the device is not in state DASD_STATE_NEW we want to
172 * keep the reference count > 0.
174 dasd_get_device(device);
177 rc = dasd_alloc_queue(device->block);
179 dasd_put_device(device);
183 device->state = DASD_STATE_KNOWN;
188 * Let the system forget about a device.
190 static int dasd_state_known_to_new(struct dasd_device *device)
192 /* Disable extended error reporting for this device. */
193 dasd_eer_disable(device);
194 /* Forget the discipline information. */
195 if (device->discipline) {
196 if (device->discipline->uncheck_device)
197 device->discipline->uncheck_device(device);
198 module_put(device->discipline->owner);
200 device->discipline = NULL;
201 if (device->base_discipline)
202 module_put(device->base_discipline->owner);
203 device->base_discipline = NULL;
204 device->state = DASD_STATE_NEW;
207 dasd_free_queue(device->block);
209 /* Give up reference we took in dasd_state_new_to_known. */
210 dasd_put_device(device);
215 * Request the irq line for the device.
217 static int dasd_state_known_to_basic(struct dasd_device *device)
221 /* Allocate and register gendisk structure. */
223 rc = dasd_gendisk_alloc(device->block);
227 /* register 'device' debug area, used for all DBF_DEV_XXX calls */
228 device->debug_area = debug_register(dev_name(&device->cdev->dev), 4, 1,
230 debug_register_view(device->debug_area, &debug_sprintf_view);
231 debug_set_level(device->debug_area, DBF_WARNING);
232 DBF_DEV_EVENT(DBF_EMERG, device, "%s", "debug area created");
234 device->state = DASD_STATE_BASIC;
239 * Release the irq line for the device. Terminate any running i/o.
241 static int dasd_state_basic_to_known(struct dasd_device *device)
245 dasd_gendisk_free(device->block);
246 dasd_block_clear_timer(device->block);
248 rc = dasd_flush_device_queue(device);
251 dasd_device_clear_timer(device);
253 DBF_DEV_EVENT(DBF_EMERG, device, "%p debug area deleted", device);
254 if (device->debug_area != NULL) {
255 debug_unregister(device->debug_area);
256 device->debug_area = NULL;
258 device->state = DASD_STATE_KNOWN;
263 * Do the initial analysis. The do_analysis function may return
264 * -EAGAIN in which case the device keeps the state DASD_STATE_BASIC
265 * until the discipline decides to continue the startup sequence
266 * by calling the function dasd_change_state. The eckd disciplines
267 * uses this to start a ccw that detects the format. The completion
268 * interrupt for this detection ccw uses the kernel event daemon to
269 * trigger the call to dasd_change_state. All this is done in the
270 * discipline code, see dasd_eckd.c.
271 * After the analysis ccw is done (do_analysis returned 0) the block
273 * In case the analysis returns an error, the device setup is stopped
274 * (a fake disk was already added to allow formatting).
276 static int dasd_state_basic_to_ready(struct dasd_device *device)
279 struct dasd_block *block;
282 block = device->block;
283 /* make disk known with correct capacity */
285 if (block->base->discipline->do_analysis != NULL)
286 rc = block->base->discipline->do_analysis(block);
289 device->state = DASD_STATE_UNFMT;
292 dasd_setup_queue(block);
293 set_capacity(block->gdp,
294 block->blocks << block->s2b_shift);
295 device->state = DASD_STATE_READY;
296 rc = dasd_scan_partitions(block);
298 device->state = DASD_STATE_BASIC;
300 device->state = DASD_STATE_READY;
306 * Remove device from block device layer. Destroy dirty buffers.
307 * Forget format information. Check if the target level is basic
308 * and if it is create fake disk for formatting.
310 static int dasd_state_ready_to_basic(struct dasd_device *device)
314 device->state = DASD_STATE_BASIC;
316 struct dasd_block *block = device->block;
317 rc = dasd_flush_block_queue(block);
319 device->state = DASD_STATE_READY;
322 dasd_destroy_partitions(block);
323 dasd_flush_request_queue(block);
326 block->s2b_shift = 0;
334 static int dasd_state_unfmt_to_basic(struct dasd_device *device)
336 device->state = DASD_STATE_BASIC;
341 * Make the device online and schedule the bottom half to start
342 * the requeueing of requests from the linux request queue to the
346 dasd_state_ready_to_online(struct dasd_device * device)
349 struct gendisk *disk;
350 struct disk_part_iter piter;
351 struct hd_struct *part;
353 if (device->discipline->ready_to_online) {
354 rc = device->discipline->ready_to_online(device);
358 device->state = DASD_STATE_ONLINE;
360 dasd_schedule_block_bh(device->block);
361 disk = device->block->bdev->bd_disk;
362 disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
363 while ((part = disk_part_iter_next(&piter)))
364 kobject_uevent(&part_to_dev(part)->kobj, KOBJ_CHANGE);
365 disk_part_iter_exit(&piter);
371 * Stop the requeueing of requests again.
373 static int dasd_state_online_to_ready(struct dasd_device *device)
376 struct gendisk *disk;
377 struct disk_part_iter piter;
378 struct hd_struct *part;
380 if (device->discipline->online_to_ready) {
381 rc = device->discipline->online_to_ready(device);
385 device->state = DASD_STATE_READY;
387 disk = device->block->bdev->bd_disk;
388 disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
389 while ((part = disk_part_iter_next(&piter)))
390 kobject_uevent(&part_to_dev(part)->kobj, KOBJ_CHANGE);
391 disk_part_iter_exit(&piter);
397 * Device startup state changes.
399 static int dasd_increase_state(struct dasd_device *device)
404 if (device->state == DASD_STATE_NEW &&
405 device->target >= DASD_STATE_KNOWN)
406 rc = dasd_state_new_to_known(device);
409 device->state == DASD_STATE_KNOWN &&
410 device->target >= DASD_STATE_BASIC)
411 rc = dasd_state_known_to_basic(device);
414 device->state == DASD_STATE_BASIC &&
415 device->target >= DASD_STATE_READY)
416 rc = dasd_state_basic_to_ready(device);
419 device->state == DASD_STATE_UNFMT &&
420 device->target > DASD_STATE_UNFMT)
424 device->state == DASD_STATE_READY &&
425 device->target >= DASD_STATE_ONLINE)
426 rc = dasd_state_ready_to_online(device);
432 * Device shutdown state changes.
434 static int dasd_decrease_state(struct dasd_device *device)
439 if (device->state == DASD_STATE_ONLINE &&
440 device->target <= DASD_STATE_READY)
441 rc = dasd_state_online_to_ready(device);
444 device->state == DASD_STATE_READY &&
445 device->target <= DASD_STATE_BASIC)
446 rc = dasd_state_ready_to_basic(device);
449 device->state == DASD_STATE_UNFMT &&
450 device->target <= DASD_STATE_BASIC)
451 rc = dasd_state_unfmt_to_basic(device);
454 device->state == DASD_STATE_BASIC &&
455 device->target <= DASD_STATE_KNOWN)
456 rc = dasd_state_basic_to_known(device);
459 device->state == DASD_STATE_KNOWN &&
460 device->target <= DASD_STATE_NEW)
461 rc = dasd_state_known_to_new(device);
467 * This is the main startup/shutdown routine.
469 static void dasd_change_state(struct dasd_device *device)
473 if (device->state == device->target)
474 /* Already where we want to go today... */
476 if (device->state < device->target)
477 rc = dasd_increase_state(device);
479 rc = dasd_decrease_state(device);
480 if (rc && rc != -EAGAIN)
481 device->target = device->state;
483 if (device->state == device->target)
484 wake_up(&dasd_init_waitq);
486 /* let user-space know that the device status changed */
487 kobject_uevent(&device->cdev->dev.kobj, KOBJ_CHANGE);
491 * Kick starter for devices that did not complete the startup/shutdown
492 * procedure or were sleeping because of a pending state.
493 * dasd_kick_device will schedule a call do do_kick_device to the kernel
496 static void do_kick_device(struct work_struct *work)
498 struct dasd_device *device = container_of(work, struct dasd_device, kick_work);
499 dasd_change_state(device);
500 dasd_schedule_device_bh(device);
501 dasd_put_device(device);
504 void dasd_kick_device(struct dasd_device *device)
506 dasd_get_device(device);
507 /* queue call to dasd_kick_device to the kernel event daemon. */
508 schedule_work(&device->kick_work);
512 * Set the target state for a device and starts the state change.
514 void dasd_set_target_state(struct dasd_device *device, int target)
516 /* If we are in probeonly mode stop at DASD_STATE_READY. */
517 if (dasd_probeonly && target > DASD_STATE_READY)
518 target = DASD_STATE_READY;
519 if (device->target != target) {
520 if (device->state == target)
521 wake_up(&dasd_init_waitq);
522 device->target = target;
524 if (device->state != device->target)
525 dasd_change_state(device);
529 * Enable devices with device numbers in [from..to].
531 static inline int _wait_for_device(struct dasd_device *device)
533 return (device->state == device->target);
536 void dasd_enable_device(struct dasd_device *device)
538 dasd_set_target_state(device, DASD_STATE_ONLINE);
539 if (device->state <= DASD_STATE_KNOWN)
540 /* No discipline for device found. */
541 dasd_set_target_state(device, DASD_STATE_NEW);
542 /* Now wait for the devices to come up. */
543 wait_event(dasd_init_waitq, _wait_for_device(device));
547 * SECTION: device operation (interrupt handler, start i/o, term i/o ...)
549 #ifdef CONFIG_DASD_PROFILE
551 struct dasd_profile_info_t dasd_global_profile;
552 unsigned int dasd_profile_level = DASD_PROFILE_OFF;
555 * Increments counter in global and local profiling structures.
557 #define dasd_profile_counter(value, counter, block) \
560 for (index = 0; index < 31 && value >> (2+index); index++); \
561 dasd_global_profile.counter[index]++; \
562 block->profile.counter[index]++; \
566 * Add profiling information for cqr before execution.
568 static void dasd_profile_start(struct dasd_block *block,
569 struct dasd_ccw_req *cqr,
573 unsigned int counter;
575 if (dasd_profile_level != DASD_PROFILE_ON)
578 /* count the length of the chanq for statistics */
580 list_for_each(l, &block->ccw_queue)
583 dasd_global_profile.dasd_io_nr_req[counter]++;
584 block->profile.dasd_io_nr_req[counter]++;
588 * Add profiling information for cqr after execution.
590 static void dasd_profile_end(struct dasd_block *block,
591 struct dasd_ccw_req *cqr,
594 long strtime, irqtime, endtime, tottime; /* in microseconds */
595 long tottimeps, sectors;
597 if (dasd_profile_level != DASD_PROFILE_ON)
600 sectors = req->nr_sectors;
601 if (!cqr->buildclk || !cqr->startclk ||
602 !cqr->stopclk || !cqr->endclk ||
606 strtime = ((cqr->startclk - cqr->buildclk) >> 12);
607 irqtime = ((cqr->stopclk - cqr->startclk) >> 12);
608 endtime = ((cqr->endclk - cqr->stopclk) >> 12);
609 tottime = ((cqr->endclk - cqr->buildclk) >> 12);
610 tottimeps = tottime / sectors;
612 if (!dasd_global_profile.dasd_io_reqs)
613 memset(&dasd_global_profile, 0,
614 sizeof(struct dasd_profile_info_t));
615 dasd_global_profile.dasd_io_reqs++;
616 dasd_global_profile.dasd_io_sects += sectors;
618 if (!block->profile.dasd_io_reqs)
619 memset(&block->profile, 0,
620 sizeof(struct dasd_profile_info_t));
621 block->profile.dasd_io_reqs++;
622 block->profile.dasd_io_sects += sectors;
624 dasd_profile_counter(sectors, dasd_io_secs, block);
625 dasd_profile_counter(tottime, dasd_io_times, block);
626 dasd_profile_counter(tottimeps, dasd_io_timps, block);
627 dasd_profile_counter(strtime, dasd_io_time1, block);
628 dasd_profile_counter(irqtime, dasd_io_time2, block);
629 dasd_profile_counter(irqtime / sectors, dasd_io_time2ps, block);
630 dasd_profile_counter(endtime, dasd_io_time3, block);
633 #define dasd_profile_start(block, cqr, req) do {} while (0)
634 #define dasd_profile_end(block, cqr, req) do {} while (0)
635 #endif /* CONFIG_DASD_PROFILE */
638 * Allocate memory for a channel program with 'cplength' channel
639 * command words and 'datasize' additional space. There are two
640 * variantes: 1) dasd_kmalloc_request uses kmalloc to get the needed
641 * memory and 2) dasd_smalloc_request uses the static ccw memory
642 * that gets allocated for each device.
644 struct dasd_ccw_req *dasd_kmalloc_request(char *magic, int cplength,
646 struct dasd_device *device)
648 struct dasd_ccw_req *cqr;
651 BUG_ON( magic == NULL || datasize > PAGE_SIZE ||
652 (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
654 cqr = kzalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC);
656 return ERR_PTR(-ENOMEM);
659 cqr->cpaddr = kcalloc(cplength, sizeof(struct ccw1),
660 GFP_ATOMIC | GFP_DMA);
661 if (cqr->cpaddr == NULL) {
663 return ERR_PTR(-ENOMEM);
668 cqr->data = kzalloc(datasize, GFP_ATOMIC | GFP_DMA);
669 if (cqr->data == NULL) {
672 return ERR_PTR(-ENOMEM);
675 strncpy((char *) &cqr->magic, magic, 4);
676 ASCEBC((char *) &cqr->magic, 4);
677 set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
678 dasd_get_device(device);
682 struct dasd_ccw_req *dasd_smalloc_request(char *magic, int cplength,
684 struct dasd_device *device)
687 struct dasd_ccw_req *cqr;
692 BUG_ON( magic == NULL || datasize > PAGE_SIZE ||
693 (cplength*sizeof(struct ccw1)) > PAGE_SIZE);
695 size = (sizeof(struct dasd_ccw_req) + 7L) & -8L;
697 size += cplength * sizeof(struct ccw1);
700 spin_lock_irqsave(&device->mem_lock, flags);
701 cqr = (struct dasd_ccw_req *)
702 dasd_alloc_chunk(&device->ccw_chunks, size);
703 spin_unlock_irqrestore(&device->mem_lock, flags);
705 return ERR_PTR(-ENOMEM);
706 memset(cqr, 0, sizeof(struct dasd_ccw_req));
707 data = (char *) cqr + ((sizeof(struct dasd_ccw_req) + 7L) & -8L);
710 cqr->cpaddr = (struct ccw1 *) data;
711 data += cplength*sizeof(struct ccw1);
712 memset(cqr->cpaddr, 0, cplength*sizeof(struct ccw1));
717 memset(cqr->data, 0, datasize);
719 strncpy((char *) &cqr->magic, magic, 4);
720 ASCEBC((char *) &cqr->magic, 4);
721 set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
722 dasd_get_device(device);
727 * Free memory of a channel program. This function needs to free all the
728 * idal lists that might have been created by dasd_set_cda and the
729 * struct dasd_ccw_req itself.
731 void dasd_kfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device)
736 /* Clear any idals used for the request. */
739 clear_normalized_cda(ccw);
740 } while (ccw++->flags & (CCW_FLAG_CC | CCW_FLAG_DC));
745 dasd_put_device(device);
748 void dasd_sfree_request(struct dasd_ccw_req *cqr, struct dasd_device *device)
752 spin_lock_irqsave(&device->mem_lock, flags);
753 dasd_free_chunk(&device->ccw_chunks, cqr);
754 spin_unlock_irqrestore(&device->mem_lock, flags);
755 dasd_put_device(device);
759 * Check discipline magic in cqr.
761 static inline int dasd_check_cqr(struct dasd_ccw_req *cqr)
763 struct dasd_device *device;
767 device = cqr->startdev;
768 if (strncmp((char *) &cqr->magic, device->discipline->ebcname, 4)) {
769 DBF_DEV_EVENT(DBF_WARNING, device,
770 " dasd_ccw_req 0x%08x magic doesn't match"
771 " discipline 0x%08x",
773 *(unsigned int *) device->discipline->name);
780 * Terminate the current i/o and set the request to clear_pending.
781 * Timer keeps device runnig.
782 * ccw_device_clear can fail if the i/o subsystem
785 int dasd_term_IO(struct dasd_ccw_req *cqr)
787 struct dasd_device *device;
789 char errorstring[ERRORLENGTH];
792 rc = dasd_check_cqr(cqr);
796 device = (struct dasd_device *) cqr->startdev;
797 while ((retries < 5) && (cqr->status == DASD_CQR_IN_IO)) {
798 rc = ccw_device_clear(device->cdev, (long) cqr);
800 case 0: /* termination successful */
802 cqr->status = DASD_CQR_CLEAR_PENDING;
803 cqr->stopclk = get_clock();
805 DBF_DEV_EVENT(DBF_DEBUG, device,
806 "terminate cqr %p successful",
810 DBF_DEV_EVENT(DBF_ERR, device, "%s",
811 "device gone, retry");
814 DBF_DEV_EVENT(DBF_ERR, device, "%s",
819 DBF_DEV_EVENT(DBF_ERR, device, "%s",
820 "device busy, retry later");
823 /* internal error 10 - unknown rc*/
824 snprintf(errorstring, ERRORLENGTH, "10 %d", rc);
825 dev_err(&device->cdev->dev, "An error occurred in the "
826 "DASD device driver, reason=%s\n", errorstring);
832 dasd_schedule_device_bh(device);
837 * Start the i/o. This start_IO can fail if the channel is really busy.
838 * In that case set up a timer to start the request later.
840 int dasd_start_IO(struct dasd_ccw_req *cqr)
842 struct dasd_device *device;
844 char errorstring[ERRORLENGTH];
847 rc = dasd_check_cqr(cqr);
850 device = (struct dasd_device *) cqr->startdev;
851 if (cqr->retries < 0) {
852 /* internal error 14 - start_IO run out of retries */
853 sprintf(errorstring, "14 %p", cqr);
854 dev_err(&device->cdev->dev, "An error occurred in the DASD "
855 "device driver, reason=%s\n", errorstring);
856 cqr->status = DASD_CQR_ERROR;
859 cqr->startclk = get_clock();
860 cqr->starttime = jiffies;
862 if (cqr->cpmode == 1) {
863 rc = ccw_device_tm_start(device->cdev, cqr->cpaddr,
864 (long) cqr, cqr->lpm);
866 rc = ccw_device_start(device->cdev, cqr->cpaddr,
867 (long) cqr, cqr->lpm, 0);
871 cqr->status = DASD_CQR_IN_IO;
872 DBF_DEV_EVENT(DBF_DEBUG, device,
873 "start_IO: request %p started successful",
877 DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
878 "start_IO: device busy, retry later");
881 DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
882 "start_IO: request timeout, retry later");
885 /* -EACCES indicates that the request used only a
886 * subset of the available pathes and all these
888 * Do a retry with all available pathes.
890 cqr->lpm = LPM_ANYPATH;
891 DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
892 "start_IO: selected pathes gone,"
893 " retry on all pathes");
896 DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
897 "start_IO: -ENODEV device gone, retry");
900 DBF_DEV_EVENT(DBF_DEBUG, device, "%s",
901 "start_IO: -EIO device gone, retry");
904 /* internal error 11 - unknown rc */
905 snprintf(errorstring, ERRORLENGTH, "11 %d", rc);
906 dev_err(&device->cdev->dev,
907 "An error occurred in the DASD device driver, "
908 "reason=%s\n", errorstring);
916 * Timeout function for dasd devices. This is used for different purposes
917 * 1) missing interrupt handler for normal operation
918 * 2) delayed start of request where start_IO failed with -EBUSY
919 * 3) timeout for missing state change interrupts
920 * The head of the ccw queue will have status DASD_CQR_IN_IO for 1),
921 * DASD_CQR_QUEUED for 2) and 3).
923 static void dasd_device_timeout(unsigned long ptr)
926 struct dasd_device *device;
928 device = (struct dasd_device *) ptr;
929 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
930 /* re-activate request queue */
931 device->stopped &= ~DASD_STOPPED_PENDING;
932 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
933 dasd_schedule_device_bh(device);
937 * Setup timeout for a device in jiffies.
939 void dasd_device_set_timer(struct dasd_device *device, int expires)
942 del_timer(&device->timer);
944 mod_timer(&device->timer, jiffies + expires);
948 * Clear timeout for a device.
950 void dasd_device_clear_timer(struct dasd_device *device)
952 del_timer(&device->timer);
955 static void dasd_handle_killed_request(struct ccw_device *cdev,
956 unsigned long intparm)
958 struct dasd_ccw_req *cqr;
959 struct dasd_device *device;
963 cqr = (struct dasd_ccw_req *) intparm;
964 if (cqr->status != DASD_CQR_IN_IO) {
966 "invalid status in handle_killed_request: "
967 "bus_id %s, status %02x",
968 dev_name(&cdev->dev), cqr->status);
972 device = (struct dasd_device *) cqr->startdev;
973 if (device == NULL ||
974 device != dasd_device_from_cdev_locked(cdev) ||
975 strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) {
976 DBF_DEV_EVENT(DBF_DEBUG, device, "invalid device in request: "
977 "bus_id %s", dev_name(&cdev->dev));
981 /* Schedule request to be retried. */
982 cqr->status = DASD_CQR_QUEUED;
984 dasd_device_clear_timer(device);
985 dasd_schedule_device_bh(device);
986 dasd_put_device(device);
989 void dasd_generic_handle_state_change(struct dasd_device *device)
991 /* First of all start sense subsystem status request. */
992 dasd_eer_snss(device);
994 device->stopped &= ~DASD_STOPPED_PENDING;
995 dasd_schedule_device_bh(device);
997 dasd_schedule_block_bh(device->block);
1001 * Interrupt handler for "normal" ssch-io based dasd devices.
1003 void dasd_int_handler(struct ccw_device *cdev, unsigned long intparm,
1006 struct dasd_ccw_req *cqr, *next;
1007 struct dasd_device *device;
1008 unsigned long long now;
1012 switch (PTR_ERR(irb)) {
1016 DBF_EVENT(DBF_WARNING, "%s(%s): request timed out\n",
1017 __func__, dev_name(&cdev->dev));
1020 DBF_EVENT(DBF_WARNING, "%s(%s): unknown error %ld\n",
1021 __func__, dev_name(&cdev->dev), PTR_ERR(irb));
1023 dasd_handle_killed_request(cdev, intparm);
1029 /* check for unsolicited interrupts */
1030 cqr = (struct dasd_ccw_req *) intparm;
1031 if (!cqr || ((scsw_cc(&irb->scsw) == 1) &&
1032 (scsw_fctl(&irb->scsw) & SCSW_FCTL_START_FUNC) &&
1033 (scsw_stctl(&irb->scsw) & SCSW_STCTL_STATUS_PEND))) {
1034 if (cqr && cqr->status == DASD_CQR_IN_IO)
1035 cqr->status = DASD_CQR_QUEUED;
1036 device = dasd_device_from_cdev_locked(cdev);
1037 if (!IS_ERR(device)) {
1038 dasd_device_clear_timer(device);
1039 device->discipline->handle_unsolicited_interrupt(device,
1041 dasd_put_device(device);
1046 device = (struct dasd_device *) cqr->startdev;
1048 strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) {
1049 DBF_DEV_EVENT(DBF_DEBUG, device, "invalid device in request: "
1050 "bus_id %s", dev_name(&cdev->dev));
1054 /* Check for clear pending */
1055 if (cqr->status == DASD_CQR_CLEAR_PENDING &&
1056 scsw_fctl(&irb->scsw) & SCSW_FCTL_CLEAR_FUNC) {
1057 cqr->status = DASD_CQR_CLEARED;
1058 dasd_device_clear_timer(device);
1059 wake_up(&dasd_flush_wq);
1060 dasd_schedule_device_bh(device);
1064 /* check status - the request might have been killed by dyn detach */
1065 if (cqr->status != DASD_CQR_IN_IO) {
1066 DBF_DEV_EVENT(DBF_DEBUG, device, "invalid status: bus_id %s, "
1067 "status %02x", dev_name(&cdev->dev), cqr->status);
1073 if (scsw_dstat(&irb->scsw) == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) &&
1074 scsw_cstat(&irb->scsw) == 0) {
1075 /* request was completed successfully */
1076 cqr->status = DASD_CQR_SUCCESS;
1078 /* Start first request on queue if possible -> fast_io. */
1079 if (cqr->devlist.next != &device->ccw_queue) {
1080 next = list_entry(cqr->devlist.next,
1081 struct dasd_ccw_req, devlist);
1083 } else { /* error */
1084 memcpy(&cqr->irb, irb, sizeof(struct irb));
1085 /* log sense for every failed I/O to s390 debugfeature */
1086 dasd_log_sense_dbf(cqr, irb);
1087 if (device->features & DASD_FEATURE_ERPLOG) {
1088 dasd_log_sense(cqr, irb);
1092 * If we don't want complex ERP for this request, then just
1093 * reset this and retry it in the fastpath
1095 if (!test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags) &&
1097 if (cqr->lpm == LPM_ANYPATH)
1098 DBF_DEV_EVENT(DBF_DEBUG, device,
1099 "default ERP in fastpath "
1100 "(%i retries left)",
1102 cqr->lpm = LPM_ANYPATH;
1103 cqr->status = DASD_CQR_QUEUED;
1106 cqr->status = DASD_CQR_ERROR;
1108 if (next && (next->status == DASD_CQR_QUEUED) &&
1109 (!device->stopped)) {
1110 if (device->discipline->start_IO(next) == 0)
1111 expires = next->expires;
1114 dasd_device_set_timer(device, expires);
1116 dasd_device_clear_timer(device);
1117 dasd_schedule_device_bh(device);
1121 * If we have an error on a dasd_block layer request then we cancel
1122 * and return all further requests from the same dasd_block as well.
1124 static void __dasd_device_recovery(struct dasd_device *device,
1125 struct dasd_ccw_req *ref_cqr)
1127 struct list_head *l, *n;
1128 struct dasd_ccw_req *cqr;
1131 * only requeue request that came from the dasd_block layer
1133 if (!ref_cqr->block)
1136 list_for_each_safe(l, n, &device->ccw_queue) {
1137 cqr = list_entry(l, struct dasd_ccw_req, devlist);
1138 if (cqr->status == DASD_CQR_QUEUED &&
1139 ref_cqr->block == cqr->block) {
1140 cqr->status = DASD_CQR_CLEARED;
1146 * Remove those ccw requests from the queue that need to be returned
1147 * to the upper layer.
1149 static void __dasd_device_process_ccw_queue(struct dasd_device *device,
1150 struct list_head *final_queue)
1152 struct list_head *l, *n;
1153 struct dasd_ccw_req *cqr;
1155 /* Process request with final status. */
1156 list_for_each_safe(l, n, &device->ccw_queue) {
1157 cqr = list_entry(l, struct dasd_ccw_req, devlist);
1159 /* Stop list processing at the first non-final request. */
1160 if (cqr->status == DASD_CQR_QUEUED ||
1161 cqr->status == DASD_CQR_IN_IO ||
1162 cqr->status == DASD_CQR_CLEAR_PENDING)
1164 if (cqr->status == DASD_CQR_ERROR) {
1165 __dasd_device_recovery(device, cqr);
1167 /* Rechain finished requests to final queue */
1168 list_move_tail(&cqr->devlist, final_queue);
1173 * the cqrs from the final queue are returned to the upper layer
1174 * by setting a dasd_block state and calling the callback function
1176 static void __dasd_device_process_final_queue(struct dasd_device *device,
1177 struct list_head *final_queue)
1179 struct list_head *l, *n;
1180 struct dasd_ccw_req *cqr;
1181 struct dasd_block *block;
1182 void (*callback)(struct dasd_ccw_req *, void *data);
1183 void *callback_data;
1184 char errorstring[ERRORLENGTH];
1186 list_for_each_safe(l, n, final_queue) {
1187 cqr = list_entry(l, struct dasd_ccw_req, devlist);
1188 list_del_init(&cqr->devlist);
1190 callback = cqr->callback;
1191 callback_data = cqr->callback_data;
1193 spin_lock_bh(&block->queue_lock);
1194 switch (cqr->status) {
1195 case DASD_CQR_SUCCESS:
1196 cqr->status = DASD_CQR_DONE;
1198 case DASD_CQR_ERROR:
1199 cqr->status = DASD_CQR_NEED_ERP;
1201 case DASD_CQR_CLEARED:
1202 cqr->status = DASD_CQR_TERMINATED;
1205 /* internal error 12 - wrong cqr status*/
1206 snprintf(errorstring, ERRORLENGTH, "12 %p %x02", cqr, cqr->status);
1207 dev_err(&device->cdev->dev,
1208 "An error occurred in the DASD device driver, "
1209 "reason=%s\n", errorstring);
1212 if (cqr->callback != NULL)
1213 (callback)(cqr, callback_data);
1215 spin_unlock_bh(&block->queue_lock);
1220 * Take a look at the first request on the ccw queue and check
1221 * if it reached its expire time. If so, terminate the IO.
1223 static void __dasd_device_check_expire(struct dasd_device *device)
1225 struct dasd_ccw_req *cqr;
1227 if (list_empty(&device->ccw_queue))
1229 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist);
1230 if ((cqr->status == DASD_CQR_IN_IO && cqr->expires != 0) &&
1231 (time_after_eq(jiffies, cqr->expires + cqr->starttime))) {
1232 if (device->discipline->term_IO(cqr) != 0) {
1233 /* Hmpf, try again in 5 sec */
1234 dev_err(&device->cdev->dev,
1235 "cqr %p timed out (%is) but cannot be "
1236 "ended, retrying in 5 s\n",
1237 cqr, (cqr->expires/HZ));
1238 cqr->expires += 5*HZ;
1239 dasd_device_set_timer(device, 5*HZ);
1241 dev_err(&device->cdev->dev,
1242 "cqr %p timed out (%is), %i retries "
1243 "remaining\n", cqr, (cqr->expires/HZ),
1250 * Take a look at the first request on the ccw queue and check
1251 * if it needs to be started.
1253 static void __dasd_device_start_head(struct dasd_device *device)
1255 struct dasd_ccw_req *cqr;
1258 if (list_empty(&device->ccw_queue))
1260 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist);
1261 if (cqr->status != DASD_CQR_QUEUED)
1263 /* when device is stopped, return request to previous layer */
1264 if (device->stopped) {
1265 cqr->status = DASD_CQR_CLEARED;
1266 dasd_schedule_device_bh(device);
1270 rc = device->discipline->start_IO(cqr);
1272 dasd_device_set_timer(device, cqr->expires);
1273 else if (rc == -EACCES) {
1274 dasd_schedule_device_bh(device);
1276 /* Hmpf, try again in 1/2 sec */
1277 dasd_device_set_timer(device, 50);
1281 * Go through all request on the dasd_device request queue,
1282 * terminate them on the cdev if necessary, and return them to the
1283 * submitting layer via callback.
1285 * Make sure that all 'submitting layers' still exist when
1286 * this function is called!. In other words, when 'device' is a base
1287 * device then all block layer requests must have been removed before
1288 * via dasd_flush_block_queue.
1290 int dasd_flush_device_queue(struct dasd_device *device)
1292 struct dasd_ccw_req *cqr, *n;
1294 struct list_head flush_queue;
1296 INIT_LIST_HEAD(&flush_queue);
1297 spin_lock_irq(get_ccwdev_lock(device->cdev));
1299 list_for_each_entry_safe(cqr, n, &device->ccw_queue, devlist) {
1300 /* Check status and move request to flush_queue */
1301 switch (cqr->status) {
1302 case DASD_CQR_IN_IO:
1303 rc = device->discipline->term_IO(cqr);
1305 /* unable to terminate requeust */
1306 dev_err(&device->cdev->dev,
1307 "Flushing the DASD request queue "
1308 "failed for request %p\n", cqr);
1309 /* stop flush processing */
1313 case DASD_CQR_QUEUED:
1314 cqr->stopclk = get_clock();
1315 cqr->status = DASD_CQR_CLEARED;
1317 default: /* no need to modify the others */
1320 list_move_tail(&cqr->devlist, &flush_queue);
1323 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1325 * After this point all requests must be in state CLEAR_PENDING,
1326 * CLEARED, SUCCESS or ERROR. Now wait for CLEAR_PENDING to become
1327 * one of the others.
1329 list_for_each_entry_safe(cqr, n, &flush_queue, devlist)
1330 wait_event(dasd_flush_wq,
1331 (cqr->status != DASD_CQR_CLEAR_PENDING));
1333 * Now set each request back to TERMINATED, DONE or NEED_ERP
1334 * and call the callback function of flushed requests
1336 __dasd_device_process_final_queue(device, &flush_queue);
1341 * Acquire the device lock and process queues for the device.
1343 static void dasd_device_tasklet(struct dasd_device *device)
1345 struct list_head final_queue;
1347 atomic_set (&device->tasklet_scheduled, 0);
1348 INIT_LIST_HEAD(&final_queue);
1349 spin_lock_irq(get_ccwdev_lock(device->cdev));
1350 /* Check expire time of first request on the ccw queue. */
1351 __dasd_device_check_expire(device);
1352 /* find final requests on ccw queue */
1353 __dasd_device_process_ccw_queue(device, &final_queue);
1354 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1355 /* Now call the callback function of requests with final status */
1356 __dasd_device_process_final_queue(device, &final_queue);
1357 spin_lock_irq(get_ccwdev_lock(device->cdev));
1358 /* Now check if the head of the ccw queue needs to be started. */
1359 __dasd_device_start_head(device);
1360 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1361 dasd_put_device(device);
1365 * Schedules a call to dasd_tasklet over the device tasklet.
1367 void dasd_schedule_device_bh(struct dasd_device *device)
1369 /* Protect against rescheduling. */
1370 if (atomic_cmpxchg (&device->tasklet_scheduled, 0, 1) != 0)
1372 dasd_get_device(device);
1373 tasklet_hi_schedule(&device->tasklet);
1377 * Queue a request to the head of the device ccw_queue.
1378 * Start the I/O if possible.
1380 void dasd_add_request_head(struct dasd_ccw_req *cqr)
1382 struct dasd_device *device;
1383 unsigned long flags;
1385 device = cqr->startdev;
1386 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
1387 cqr->status = DASD_CQR_QUEUED;
1388 list_add(&cqr->devlist, &device->ccw_queue);
1389 /* let the bh start the request to keep them in order */
1390 dasd_schedule_device_bh(device);
1391 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
1395 * Queue a request to the tail of the device ccw_queue.
1396 * Start the I/O if possible.
1398 void dasd_add_request_tail(struct dasd_ccw_req *cqr)
1400 struct dasd_device *device;
1401 unsigned long flags;
1403 device = cqr->startdev;
1404 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
1405 cqr->status = DASD_CQR_QUEUED;
1406 list_add_tail(&cqr->devlist, &device->ccw_queue);
1407 /* let the bh start the request to keep them in order */
1408 dasd_schedule_device_bh(device);
1409 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
1413 * Wakeup helper for the 'sleep_on' functions.
1415 static void dasd_wakeup_cb(struct dasd_ccw_req *cqr, void *data)
1417 wake_up((wait_queue_head_t *) data);
1420 static inline int _wait_for_wakeup(struct dasd_ccw_req *cqr)
1422 struct dasd_device *device;
1425 device = cqr->startdev;
1426 spin_lock_irq(get_ccwdev_lock(device->cdev));
1427 rc = ((cqr->status == DASD_CQR_DONE ||
1428 cqr->status == DASD_CQR_NEED_ERP ||
1429 cqr->status == DASD_CQR_TERMINATED) &&
1430 list_empty(&cqr->devlist));
1431 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1436 * Queue a request to the tail of the device ccw_queue and wait for
1439 int dasd_sleep_on(struct dasd_ccw_req *cqr)
1441 struct dasd_device *device;
1444 device = cqr->startdev;
1446 cqr->callback = dasd_wakeup_cb;
1447 cqr->callback_data = (void *) &generic_waitq;
1448 dasd_add_request_tail(cqr);
1449 wait_event(generic_waitq, _wait_for_wakeup(cqr));
1451 /* Request status is either done or failed. */
1452 rc = (cqr->status == DASD_CQR_DONE) ? 0 : -EIO;
1457 * Queue a request to the tail of the device ccw_queue and wait
1458 * interruptible for it's completion.
1460 int dasd_sleep_on_interruptible(struct dasd_ccw_req *cqr)
1462 struct dasd_device *device;
1465 device = cqr->startdev;
1466 cqr->callback = dasd_wakeup_cb;
1467 cqr->callback_data = (void *) &generic_waitq;
1468 dasd_add_request_tail(cqr);
1469 rc = wait_event_interruptible(generic_waitq, _wait_for_wakeup(cqr));
1470 if (rc == -ERESTARTSYS) {
1471 dasd_cancel_req(cqr);
1472 /* wait (non-interruptible) for final status */
1473 wait_event(generic_waitq, _wait_for_wakeup(cqr));
1475 rc = (cqr->status == DASD_CQR_DONE) ? 0 : -EIO;
1480 * Whoa nelly now it gets really hairy. For some functions (e.g. steal lock
1481 * for eckd devices) the currently running request has to be terminated
1482 * and be put back to status queued, before the special request is added
1483 * to the head of the queue. Then the special request is waited on normally.
1485 static inline int _dasd_term_running_cqr(struct dasd_device *device)
1487 struct dasd_ccw_req *cqr;
1489 if (list_empty(&device->ccw_queue))
1491 cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, devlist);
1492 return device->discipline->term_IO(cqr);
1495 int dasd_sleep_on_immediatly(struct dasd_ccw_req *cqr)
1497 struct dasd_device *device;
1500 device = cqr->startdev;
1501 spin_lock_irq(get_ccwdev_lock(device->cdev));
1502 rc = _dasd_term_running_cqr(device);
1504 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1508 cqr->callback = dasd_wakeup_cb;
1509 cqr->callback_data = (void *) &generic_waitq;
1510 cqr->status = DASD_CQR_QUEUED;
1511 list_add(&cqr->devlist, &device->ccw_queue);
1513 /* let the bh start the request to keep them in order */
1514 dasd_schedule_device_bh(device);
1516 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1518 wait_event(generic_waitq, _wait_for_wakeup(cqr));
1520 /* Request status is either done or failed. */
1521 rc = (cqr->status == DASD_CQR_DONE) ? 0 : -EIO;
1526 * Cancels a request that was started with dasd_sleep_on_req.
1527 * This is useful to timeout requests. The request will be
1528 * terminated if it is currently in i/o.
1529 * Returns 1 if the request has been terminated.
1530 * 0 if there was no need to terminate the request (not started yet)
1531 * negative error code if termination failed
1532 * Cancellation of a request is an asynchronous operation! The calling
1533 * function has to wait until the request is properly returned via callback.
1535 int dasd_cancel_req(struct dasd_ccw_req *cqr)
1537 struct dasd_device *device = cqr->startdev;
1538 unsigned long flags;
1542 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
1543 switch (cqr->status) {
1544 case DASD_CQR_QUEUED:
1545 /* request was not started - just set to cleared */
1546 cqr->status = DASD_CQR_CLEARED;
1548 case DASD_CQR_IN_IO:
1549 /* request in IO - terminate IO and release again */
1550 rc = device->discipline->term_IO(cqr);
1552 dev_err(&device->cdev->dev,
1553 "Cancelling request %p failed with rc=%d\n",
1556 cqr->stopclk = get_clock();
1560 default: /* already finished or clear pending - do nothing */
1563 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
1564 dasd_schedule_device_bh(device);
1570 * SECTION: Operations of the dasd_block layer.
1574 * Timeout function for dasd_block. This is used when the block layer
1575 * is waiting for something that may not come reliably, (e.g. a state
1578 static void dasd_block_timeout(unsigned long ptr)
1580 unsigned long flags;
1581 struct dasd_block *block;
1583 block = (struct dasd_block *) ptr;
1584 spin_lock_irqsave(get_ccwdev_lock(block->base->cdev), flags);
1585 /* re-activate request queue */
1586 block->base->stopped &= ~DASD_STOPPED_PENDING;
1587 spin_unlock_irqrestore(get_ccwdev_lock(block->base->cdev), flags);
1588 dasd_schedule_block_bh(block);
1592 * Setup timeout for a dasd_block in jiffies.
1594 void dasd_block_set_timer(struct dasd_block *block, int expires)
1597 del_timer(&block->timer);
1599 mod_timer(&block->timer, jiffies + expires);
1603 * Clear timeout for a dasd_block.
1605 void dasd_block_clear_timer(struct dasd_block *block)
1607 del_timer(&block->timer);
1611 * posts the buffer_cache about a finalized request
1613 static inline void dasd_end_request(struct request *req, int error)
1615 if (__blk_end_request(req, error, blk_rq_bytes(req)))
1620 * Process finished error recovery ccw.
1622 static inline void __dasd_block_process_erp(struct dasd_block *block,
1623 struct dasd_ccw_req *cqr)
1625 dasd_erp_fn_t erp_fn;
1626 struct dasd_device *device = block->base;
1628 if (cqr->status == DASD_CQR_DONE)
1629 DBF_DEV_EVENT(DBF_NOTICE, device, "%s", "ERP successful");
1631 dev_err(&device->cdev->dev, "ERP failed for the DASD\n");
1632 erp_fn = device->discipline->erp_postaction(cqr);
1637 * Fetch requests from the block device queue.
1639 static void __dasd_process_request_queue(struct dasd_block *block)
1641 struct request_queue *queue;
1642 struct request *req;
1643 struct dasd_ccw_req *cqr;
1644 struct dasd_device *basedev;
1645 unsigned long flags;
1646 queue = block->request_queue;
1647 basedev = block->base;
1648 /* No queue ? Then there is nothing to do. */
1653 * We requeue request from the block device queue to the ccw
1654 * queue only in two states. In state DASD_STATE_READY the
1655 * partition detection is done and we need to requeue requests
1656 * for that. State DASD_STATE_ONLINE is normal block device
1659 if (basedev->state < DASD_STATE_READY)
1661 /* Now we try to fetch requests from the request queue */
1662 while (!blk_queue_plugged(queue) &&
1663 elv_next_request(queue)) {
1665 req = elv_next_request(queue);
1667 if (basedev->features & DASD_FEATURE_READONLY &&
1668 rq_data_dir(req) == WRITE) {
1669 DBF_DEV_EVENT(DBF_ERR, basedev,
1670 "Rejecting write request %p",
1672 blkdev_dequeue_request(req);
1673 dasd_end_request(req, -EIO);
1676 cqr = basedev->discipline->build_cp(basedev, block, req);
1678 if (PTR_ERR(cqr) == -EBUSY)
1679 break; /* normal end condition */
1680 if (PTR_ERR(cqr) == -ENOMEM)
1681 break; /* terminate request queue loop */
1682 if (PTR_ERR(cqr) == -EAGAIN) {
1684 * The current request cannot be build right
1685 * now, we have to try later. If this request
1686 * is the head-of-queue we stop the device
1689 if (!list_empty(&block->ccw_queue))
1691 spin_lock_irqsave(get_ccwdev_lock(basedev->cdev), flags);
1692 basedev->stopped |= DASD_STOPPED_PENDING;
1693 spin_unlock_irqrestore(get_ccwdev_lock(basedev->cdev), flags);
1694 dasd_block_set_timer(block, HZ/2);
1697 DBF_DEV_EVENT(DBF_ERR, basedev,
1698 "CCW creation failed (rc=%ld) "
1701 blkdev_dequeue_request(req);
1702 dasd_end_request(req, -EIO);
1706 * Note: callback is set to dasd_return_cqr_cb in
1707 * __dasd_block_start_head to cover erp requests as well
1709 cqr->callback_data = (void *) req;
1710 cqr->status = DASD_CQR_FILLED;
1711 blkdev_dequeue_request(req);
1712 list_add_tail(&cqr->blocklist, &block->ccw_queue);
1713 dasd_profile_start(block, cqr, req);
1717 static void __dasd_cleanup_cqr(struct dasd_ccw_req *cqr)
1719 struct request *req;
1723 req = (struct request *) cqr->callback_data;
1724 dasd_profile_end(cqr->block, cqr, req);
1725 status = cqr->block->base->discipline->free_cp(cqr, req);
1727 error = status ? status : -EIO;
1728 dasd_end_request(req, error);
1732 * Process ccw request queue.
1734 static void __dasd_process_block_ccw_queue(struct dasd_block *block,
1735 struct list_head *final_queue)
1737 struct list_head *l, *n;
1738 struct dasd_ccw_req *cqr;
1739 dasd_erp_fn_t erp_fn;
1740 unsigned long flags;
1741 struct dasd_device *base = block->base;
1744 /* Process request with final status. */
1745 list_for_each_safe(l, n, &block->ccw_queue) {
1746 cqr = list_entry(l, struct dasd_ccw_req, blocklist);
1747 if (cqr->status != DASD_CQR_DONE &&
1748 cqr->status != DASD_CQR_FAILED &&
1749 cqr->status != DASD_CQR_NEED_ERP &&
1750 cqr->status != DASD_CQR_TERMINATED)
1753 if (cqr->status == DASD_CQR_TERMINATED) {
1754 base->discipline->handle_terminated_request(cqr);
1758 /* Process requests that may be recovered */
1759 if (cqr->status == DASD_CQR_NEED_ERP) {
1760 erp_fn = base->discipline->erp_action(cqr);
1765 /* log sense for fatal error */
1766 if (cqr->status == DASD_CQR_FAILED) {
1767 dasd_log_sense(cqr, &cqr->irb);
1770 /* First of all call extended error reporting. */
1771 if (dasd_eer_enabled(base) &&
1772 cqr->status == DASD_CQR_FAILED) {
1773 dasd_eer_write(base, cqr, DASD_EER_FATALERROR);
1775 /* restart request */
1776 cqr->status = DASD_CQR_FILLED;
1778 spin_lock_irqsave(get_ccwdev_lock(base->cdev), flags);
1779 base->stopped |= DASD_STOPPED_QUIESCE;
1780 spin_unlock_irqrestore(get_ccwdev_lock(base->cdev),
1785 /* Process finished ERP request. */
1787 __dasd_block_process_erp(block, cqr);
1791 /* Rechain finished requests to final queue */
1792 cqr->endclk = get_clock();
1793 list_move_tail(&cqr->blocklist, final_queue);
1797 static void dasd_return_cqr_cb(struct dasd_ccw_req *cqr, void *data)
1799 dasd_schedule_block_bh(cqr->block);
1802 static void __dasd_block_start_head(struct dasd_block *block)
1804 struct dasd_ccw_req *cqr;
1806 if (list_empty(&block->ccw_queue))
1808 /* We allways begin with the first requests on the queue, as some
1809 * of previously started requests have to be enqueued on a
1810 * dasd_device again for error recovery.
1812 list_for_each_entry(cqr, &block->ccw_queue, blocklist) {
1813 if (cqr->status != DASD_CQR_FILLED)
1815 /* Non-temporary stop condition will trigger fail fast */
1816 if (block->base->stopped & ~DASD_STOPPED_PENDING &&
1817 test_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags) &&
1818 (!dasd_eer_enabled(block->base))) {
1819 cqr->status = DASD_CQR_FAILED;
1820 dasd_schedule_block_bh(block);
1823 /* Don't try to start requests if device is stopped */
1824 if (block->base->stopped)
1827 /* just a fail safe check, should not happen */
1829 cqr->startdev = block->base;
1831 /* make sure that the requests we submit find their way back */
1832 cqr->callback = dasd_return_cqr_cb;
1834 dasd_add_request_tail(cqr);
1839 * Central dasd_block layer routine. Takes requests from the generic
1840 * block layer request queue, creates ccw requests, enqueues them on
1841 * a dasd_device and processes ccw requests that have been returned.
1843 static void dasd_block_tasklet(struct dasd_block *block)
1845 struct list_head final_queue;
1846 struct list_head *l, *n;
1847 struct dasd_ccw_req *cqr;
1849 atomic_set(&block->tasklet_scheduled, 0);
1850 INIT_LIST_HEAD(&final_queue);
1851 spin_lock(&block->queue_lock);
1852 /* Finish off requests on ccw queue */
1853 __dasd_process_block_ccw_queue(block, &final_queue);
1854 spin_unlock(&block->queue_lock);
1855 /* Now call the callback function of requests with final status */
1856 spin_lock_irq(&block->request_queue_lock);
1857 list_for_each_safe(l, n, &final_queue) {
1858 cqr = list_entry(l, struct dasd_ccw_req, blocklist);
1859 list_del_init(&cqr->blocklist);
1860 __dasd_cleanup_cqr(cqr);
1862 spin_lock(&block->queue_lock);
1863 /* Get new request from the block device request queue */
1864 __dasd_process_request_queue(block);
1865 /* Now check if the head of the ccw queue needs to be started. */
1866 __dasd_block_start_head(block);
1867 spin_unlock(&block->queue_lock);
1868 spin_unlock_irq(&block->request_queue_lock);
1869 dasd_put_device(block->base);
1872 static void _dasd_wake_block_flush_cb(struct dasd_ccw_req *cqr, void *data)
1874 wake_up(&dasd_flush_wq);
1878 * Go through all request on the dasd_block request queue, cancel them
1879 * on the respective dasd_device, and return them to the generic
1882 static int dasd_flush_block_queue(struct dasd_block *block)
1884 struct dasd_ccw_req *cqr, *n;
1886 struct list_head flush_queue;
1888 INIT_LIST_HEAD(&flush_queue);
1889 spin_lock_bh(&block->queue_lock);
1892 list_for_each_entry_safe(cqr, n, &block->ccw_queue, blocklist) {
1893 /* if this request currently owned by a dasd_device cancel it */
1894 if (cqr->status >= DASD_CQR_QUEUED)
1895 rc = dasd_cancel_req(cqr);
1898 /* Rechain request (including erp chain) so it won't be
1899 * touched by the dasd_block_tasklet anymore.
1900 * Replace the callback so we notice when the request
1901 * is returned from the dasd_device layer.
1903 cqr->callback = _dasd_wake_block_flush_cb;
1904 for (i = 0; cqr != NULL; cqr = cqr->refers, i++)
1905 list_move_tail(&cqr->blocklist, &flush_queue);
1907 /* moved more than one request - need to restart */
1910 spin_unlock_bh(&block->queue_lock);
1911 /* Now call the callback function of flushed requests */
1913 list_for_each_entry_safe(cqr, n, &flush_queue, blocklist) {
1914 wait_event(dasd_flush_wq, (cqr->status < DASD_CQR_QUEUED));
1915 /* Process finished ERP request. */
1917 spin_lock_bh(&block->queue_lock);
1918 __dasd_block_process_erp(block, cqr);
1919 spin_unlock_bh(&block->queue_lock);
1920 /* restart list_for_xx loop since dasd_process_erp
1921 * might remove multiple elements */
1924 /* call the callback function */
1925 spin_lock_irq(&block->request_queue_lock);
1926 cqr->endclk = get_clock();
1927 list_del_init(&cqr->blocklist);
1928 __dasd_cleanup_cqr(cqr);
1929 spin_unlock_irq(&block->request_queue_lock);
1935 * Schedules a call to dasd_tasklet over the device tasklet.
1937 void dasd_schedule_block_bh(struct dasd_block *block)
1939 /* Protect against rescheduling. */
1940 if (atomic_cmpxchg(&block->tasklet_scheduled, 0, 1) != 0)
1942 /* life cycle of block is bound to it's base device */
1943 dasd_get_device(block->base);
1944 tasklet_hi_schedule(&block->tasklet);
1949 * SECTION: external block device operations
1950 * (request queue handling, open, release, etc.)
1954 * Dasd request queue function. Called from ll_rw_blk.c
1956 static void do_dasd_request(struct request_queue *queue)
1958 struct dasd_block *block;
1960 block = queue->queuedata;
1961 spin_lock(&block->queue_lock);
1962 /* Get new request from the block device request queue */
1963 __dasd_process_request_queue(block);
1964 /* Now check if the head of the ccw queue needs to be started. */
1965 __dasd_block_start_head(block);
1966 spin_unlock(&block->queue_lock);
1970 * Allocate and initialize request queue and default I/O scheduler.
1972 static int dasd_alloc_queue(struct dasd_block *block)
1976 block->request_queue = blk_init_queue(do_dasd_request,
1977 &block->request_queue_lock);
1978 if (block->request_queue == NULL)
1981 block->request_queue->queuedata = block;
1983 elevator_exit(block->request_queue->elevator);
1984 block->request_queue->elevator = NULL;
1985 rc = elevator_init(block->request_queue, "deadline");
1987 blk_cleanup_queue(block->request_queue);
1994 * Allocate and initialize request queue.
1996 static void dasd_setup_queue(struct dasd_block *block)
2000 blk_queue_hardsect_size(block->request_queue, block->bp_block);
2001 max = block->base->discipline->max_blocks << block->s2b_shift;
2002 blk_queue_max_sectors(block->request_queue, max);
2003 blk_queue_max_phys_segments(block->request_queue, -1L);
2004 blk_queue_max_hw_segments(block->request_queue, -1L);
2005 /* with page sized segments we can translate each segement into
2008 blk_queue_max_segment_size(block->request_queue, PAGE_SIZE);
2009 blk_queue_segment_boundary(block->request_queue, PAGE_SIZE - 1);
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_info(&base->cdev->dev,
2061 "Accessing the DASD failed because it is in "
2062 "probeonly mode\n");
2067 if (base->state <= DASD_STATE_BASIC) {
2068 DBF_DEV_EVENT(DBF_ERR, base, " %s",
2069 " Cannot open unrecognized device");
2077 module_put(base->discipline->owner);
2079 atomic_dec(&block->open_count);
2083 static int dasd_release(struct gendisk *disk, fmode_t mode)
2085 struct dasd_block *block = disk->private_data;
2087 atomic_dec(&block->open_count);
2088 module_put(block->base->discipline->owner);
2093 * Return disk geometry.
2095 static int dasd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
2097 struct dasd_block *block;
2098 struct dasd_device *base;
2100 block = bdev->bd_disk->private_data;
2105 if (!base->discipline ||
2106 !base->discipline->fill_geometry)
2109 base->discipline->fill_geometry(block, geo);
2110 geo->start = get_start_sect(bdev) >> block->s2b_shift;
2114 struct block_device_operations
2115 dasd_device_operations = {
2116 .owner = THIS_MODULE,
2118 .release = dasd_release,
2119 .ioctl = dasd_ioctl,
2120 .compat_ioctl = dasd_ioctl,
2121 .getgeo = dasd_getgeo,
2124 /*******************************************************************************
2125 * end of block device operations
2131 #ifdef CONFIG_PROC_FS
2135 if (dasd_page_cache != NULL) {
2136 kmem_cache_destroy(dasd_page_cache);
2137 dasd_page_cache = NULL;
2139 dasd_gendisk_exit();
2141 if (dasd_debug_area != NULL) {
2142 debug_unregister(dasd_debug_area);
2143 dasd_debug_area = NULL;
2148 * SECTION: common functions for ccw_driver use
2152 * Initial attempt at a probe function. this can be simplified once
2153 * the other detection code is gone.
2155 int dasd_generic_probe(struct ccw_device *cdev,
2156 struct dasd_discipline *discipline)
2160 ret = ccw_device_set_options(cdev, CCWDEV_DO_PATHGROUP);
2162 DBF_EVENT(DBF_WARNING,
2163 "dasd_generic_probe: could not set ccw-device options "
2164 "for %s\n", dev_name(&cdev->dev));
2167 ret = dasd_add_sysfs_files(cdev);
2169 DBF_EVENT(DBF_WARNING,
2170 "dasd_generic_probe: could not add sysfs entries "
2171 "for %s\n", dev_name(&cdev->dev));
2174 cdev->handler = &dasd_int_handler;
2177 * Automatically online either all dasd devices (dasd_autodetect)
2178 * or all devices specified with dasd= parameters during
2181 if ((dasd_get_feature(cdev, DASD_FEATURE_INITIAL_ONLINE) > 0 ) ||
2182 (dasd_autodetect && dasd_busid_known(dev_name(&cdev->dev)) != 0))
2183 ret = ccw_device_set_online(cdev);
2185 pr_warning("%s: Setting the DASD online failed with rc=%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 pr_warning("%s Setting the DASD online failed because "
2250 "of missing DIAG discipline\n",
2251 dev_name(&cdev->dev));
2252 dasd_delete_device(device);
2255 discipline = dasd_diag_discipline_pointer;
2257 if (!try_module_get(base_discipline->owner)) {
2258 dasd_delete_device(device);
2261 if (!try_module_get(discipline->owner)) {
2262 module_put(base_discipline->owner);
2263 dasd_delete_device(device);
2266 device->base_discipline = base_discipline;
2267 device->discipline = discipline;
2269 /* check_device will allocate block device if necessary */
2270 rc = discipline->check_device(device);
2272 pr_warning("%s Setting the DASD online with discipline %s "
2273 "failed with rc=%i\n",
2274 dev_name(&cdev->dev), discipline->name, rc);
2275 module_put(discipline->owner);
2276 module_put(base_discipline->owner);
2277 dasd_delete_device(device);
2281 dasd_set_target_state(device, DASD_STATE_ONLINE);
2282 if (device->state <= DASD_STATE_KNOWN) {
2283 pr_warning("%s Setting the DASD online failed because of a "
2284 "missing discipline\n", dev_name(&cdev->dev));
2286 dasd_set_target_state(device, DASD_STATE_NEW);
2288 dasd_free_block(device->block);
2289 dasd_delete_device(device);
2291 pr_debug("dasd_generic device %s found\n",
2292 dev_name(&cdev->dev));
2294 /* FIXME: we have to wait for the root device but we don't want
2295 * to wait for each single device but for all at once. */
2296 wait_event(dasd_init_waitq, _wait_for_device(device));
2298 dasd_put_device(device);
2303 int dasd_generic_set_offline(struct ccw_device *cdev)
2305 struct dasd_device *device;
2306 struct dasd_block *block;
2307 int max_count, open_count;
2309 device = dasd_device_from_cdev(cdev);
2311 return PTR_ERR(device);
2312 if (test_and_set_bit(DASD_FLAG_OFFLINE, &device->flags)) {
2313 /* Already doing offline processing */
2314 dasd_put_device(device);
2318 * We must make sure that this device is currently not in use.
2319 * The open_count is increased for every opener, that includes
2320 * the blkdev_get in dasd_scan_partitions. We are only interested
2321 * in the other openers.
2323 if (device->block) {
2324 max_count = device->block->bdev ? 0 : -1;
2325 open_count = atomic_read(&device->block->open_count);
2326 if (open_count > max_count) {
2328 pr_warning("%s: The DASD cannot be set offline "
2329 "with open count %i\n",
2330 dev_name(&cdev->dev), open_count);
2332 pr_warning("%s: The DASD cannot be set offline "
2333 "while it is in use\n",
2334 dev_name(&cdev->dev));
2335 clear_bit(DASD_FLAG_OFFLINE, &device->flags);
2336 dasd_put_device(device);
2340 dasd_set_target_state(device, DASD_STATE_NEW);
2341 /* dasd_delete_device destroys the device reference. */
2342 block = device->block;
2343 device->block = NULL;
2344 dasd_delete_device(device);
2346 * life cycle of block is bound to device, so delete it after
2347 * device was safely removed
2350 dasd_free_block(block);
2354 int dasd_generic_notify(struct ccw_device *cdev, int event)
2356 struct dasd_device *device;
2357 struct dasd_ccw_req *cqr;
2360 device = dasd_device_from_cdev_locked(cdev);
2368 /* First of all call extended error reporting. */
2369 dasd_eer_write(device, NULL, DASD_EER_NOPATH);
2371 if (device->state < DASD_STATE_BASIC)
2373 /* Device is active. We want to keep it. */
2374 list_for_each_entry(cqr, &device->ccw_queue, devlist)
2375 if (cqr->status == DASD_CQR_IN_IO) {
2376 cqr->status = DASD_CQR_QUEUED;
2379 device->stopped |= DASD_STOPPED_DC_WAIT;
2380 dasd_device_clear_timer(device);
2381 dasd_schedule_device_bh(device);
2385 /* FIXME: add a sanity check. */
2386 device->stopped &= ~DASD_STOPPED_DC_WAIT;
2387 dasd_schedule_device_bh(device);
2389 dasd_schedule_block_bh(device->block);
2393 dasd_put_device(device);
2397 static struct dasd_ccw_req *dasd_generic_build_rdc(struct dasd_device *device,
2399 int rdc_buffer_size,
2402 struct dasd_ccw_req *cqr;
2405 cqr = dasd_smalloc_request(magic, 1 /* RDC */, rdc_buffer_size, device);
2408 /* internal error 13 - Allocating the RDC request failed*/
2409 dev_err(&device->cdev->dev,
2410 "An error occurred in the DASD device driver, "
2411 "reason=%s\n", "13");
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);
2449 * In command mode and transport mode we need to look for sense
2450 * data in different places. The sense data itself is allways
2451 * an array of 32 bytes, so we can unify the sense data access
2454 char *dasd_get_sense(struct irb *irb)
2456 struct tsb *tsb = NULL;
2459 if (scsw_is_tm(&irb->scsw) && (irb->scsw.tm.fcxs == 0x01)) {
2460 if (irb->scsw.tm.tcw)
2461 tsb = tcw_get_tsb((struct tcw *)(unsigned long)
2463 if (tsb && tsb->length == 64 && tsb->flags)
2464 switch (tsb->flags & 0x07) {
2465 case 1: /* tsa_iostat */
2466 sense = tsb->tsa.iostat.sense;
2468 case 2: /* tsa_ddpc */
2469 sense = tsb->tsa.ddpc.sense;
2472 /* currently we don't use interrogate data */
2475 } else if (irb->esw.esw0.erw.cons) {
2480 EXPORT_SYMBOL_GPL(dasd_get_sense);
2482 static int __init dasd_init(void)
2486 init_waitqueue_head(&dasd_init_waitq);
2487 init_waitqueue_head(&dasd_flush_wq);
2488 init_waitqueue_head(&generic_waitq);
2490 /* register 'common' DASD debug area, used for all DBF_XXX calls */
2491 dasd_debug_area = debug_register("dasd", 1, 1, 8 * sizeof(long));
2492 if (dasd_debug_area == NULL) {
2496 debug_register_view(dasd_debug_area, &debug_sprintf_view);
2497 debug_set_level(dasd_debug_area, DBF_WARNING);
2499 DBF_EVENT(DBF_EMERG, "%s", "debug area created");
2501 dasd_diag_discipline_pointer = NULL;
2503 rc = dasd_devmap_init();
2506 rc = dasd_gendisk_init();
2512 rc = dasd_eer_init();
2515 #ifdef CONFIG_PROC_FS
2516 rc = dasd_proc_init();
2523 pr_info("The DASD device driver could not be initialized\n");
2528 module_init(dasd_init);
2529 module_exit(dasd_exit);
2531 EXPORT_SYMBOL(dasd_debug_area);
2532 EXPORT_SYMBOL(dasd_diag_discipline_pointer);
2534 EXPORT_SYMBOL(dasd_add_request_head);
2535 EXPORT_SYMBOL(dasd_add_request_tail);
2536 EXPORT_SYMBOL(dasd_cancel_req);
2537 EXPORT_SYMBOL(dasd_device_clear_timer);
2538 EXPORT_SYMBOL(dasd_block_clear_timer);
2539 EXPORT_SYMBOL(dasd_enable_device);
2540 EXPORT_SYMBOL(dasd_int_handler);
2541 EXPORT_SYMBOL(dasd_kfree_request);
2542 EXPORT_SYMBOL(dasd_kick_device);
2543 EXPORT_SYMBOL(dasd_kmalloc_request);
2544 EXPORT_SYMBOL(dasd_schedule_device_bh);
2545 EXPORT_SYMBOL(dasd_schedule_block_bh);
2546 EXPORT_SYMBOL(dasd_set_target_state);
2547 EXPORT_SYMBOL(dasd_device_set_timer);
2548 EXPORT_SYMBOL(dasd_block_set_timer);
2549 EXPORT_SYMBOL(dasd_sfree_request);
2550 EXPORT_SYMBOL(dasd_sleep_on);
2551 EXPORT_SYMBOL(dasd_sleep_on_immediatly);
2552 EXPORT_SYMBOL(dasd_sleep_on_interruptible);
2553 EXPORT_SYMBOL(dasd_smalloc_request);
2554 EXPORT_SYMBOL(dasd_start_IO);
2555 EXPORT_SYMBOL(dasd_term_IO);
2557 EXPORT_SYMBOL_GPL(dasd_generic_probe);
2558 EXPORT_SYMBOL_GPL(dasd_generic_remove);
2559 EXPORT_SYMBOL_GPL(dasd_generic_notify);
2560 EXPORT_SYMBOL_GPL(dasd_generic_set_online);
2561 EXPORT_SYMBOL_GPL(dasd_generic_set_offline);
2562 EXPORT_SYMBOL_GPL(dasd_generic_handle_state_change);
2563 EXPORT_SYMBOL_GPL(dasd_flush_device_queue);
2564 EXPORT_SYMBOL_GPL(dasd_alloc_block);
2565 EXPORT_SYMBOL_GPL(dasd_free_block);