patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / s390 / block / dasd.c
1 /*
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
9  *
10  * $Revision: 1.142 $
11  */
12
13 #include <linux/config.h>
14 #include <linux/kmod.h>
15 #include <linux/init.h>
16 #include <linux/interrupt.h>
17 #include <linux/ctype.h>
18 #include <linux/major.h>
19 #include <linux/slab.h>
20 #include <linux/buffer_head.h>
21
22 #include <asm/ccwdev.h>
23 #include <asm/ebcdic.h>
24 #include <asm/idals.h>
25 #include <asm/todclk.h>
26
27 /* This is ugly... */
28 #define PRINTK_HEADER "dasd:"
29
30 #include "dasd_int.h"
31 /*
32  * SECTION: Constant definitions to be used within this file
33  */
34 #define DASD_CHANQ_MAX_SIZE 4
35
36 /*
37  * SECTION: exported variables of dasd.c
38  */
39 debug_info_t *dasd_debug_area;
40 struct dasd_discipline *dasd_diag_discipline_pointer;
41
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_PARM(dasd, "1-" __MODULE_STRING(256) "s");
47 MODULE_LICENSE("GPL");
48
49 /*
50  * SECTION: prototypes for static functions of dasd.c
51  */
52 static int  dasd_alloc_queue(struct dasd_device * device);
53 static void dasd_setup_queue(struct dasd_device * device);
54 static void dasd_free_queue(struct dasd_device * device);
55 static void dasd_flush_request_queue(struct dasd_device *);
56 static void dasd_int_handler(struct ccw_device *, unsigned long, struct irb *);
57 static void dasd_flush_ccw_queue(struct dasd_device *, int);
58 static void dasd_tasklet(struct dasd_device *);
59 static void do_kick_device(void *data);
60
61 /*
62  * SECTION: Operations on the device structure.
63  */
64 static wait_queue_head_t dasd_init_waitq;
65
66 /*
67  * Allocate memory for a new device structure.
68  */
69 struct dasd_device *
70 dasd_alloc_device(void)
71 {
72         struct dasd_device *device;
73
74         device = kmalloc(sizeof (struct dasd_device), GFP_ATOMIC);
75         if (device == NULL)
76                 return ERR_PTR(-ENOMEM);
77         memset(device, 0, sizeof (struct dasd_device));
78         /* open_count = 0 means device online but not in use */
79         atomic_set(&device->open_count, -1);
80
81         /* Get two pages for normal block device operations. */
82         device->ccw_mem = (void *) __get_free_pages(GFP_ATOMIC | GFP_DMA, 1);
83         if (device->ccw_mem == NULL) {
84                 kfree(device);
85                 return ERR_PTR(-ENOMEM);
86         }
87         /* Get one page for error recovery. */
88         device->erp_mem = (void *) get_zeroed_page(GFP_ATOMIC | GFP_DMA);
89         if (device->erp_mem == NULL) {
90                 free_pages((unsigned long) device->ccw_mem, 1);
91                 kfree(device);
92                 return ERR_PTR(-ENOMEM);
93         }
94
95         dasd_init_chunklist(&device->ccw_chunks, device->ccw_mem, PAGE_SIZE*2);
96         dasd_init_chunklist(&device->erp_chunks, device->erp_mem, PAGE_SIZE);
97         spin_lock_init(&device->mem_lock);
98         spin_lock_init(&device->request_queue_lock);
99         atomic_set (&device->tasklet_scheduled, 0);
100         tasklet_init(&device->tasklet, 
101                      (void (*)(unsigned long)) dasd_tasklet,
102                      (unsigned long) device);
103         INIT_LIST_HEAD(&device->ccw_queue);
104         init_timer(&device->timer);
105         INIT_WORK(&device->kick_work, do_kick_device, device);
106         device->state = DASD_STATE_NEW;
107         device->target = DASD_STATE_NEW;
108
109         return device;
110 }
111
112 /*
113  * Free memory of a device structure.
114  */
115 void
116 dasd_free_device(struct dasd_device *device)
117 {
118         if (device->private)
119                 kfree(device->private);
120         free_page((unsigned long) device->erp_mem);
121         free_pages((unsigned long) device->ccw_mem, 1);
122         kfree(device);
123 }
124
125 /*
126  * Make a new device known to the system.
127  */
128 static inline int
129 dasd_state_new_to_known(struct dasd_device *device)
130 {
131         int rc;
132
133         /*
134          * As long as the device is not in state DASD_STATE_NEW we want to 
135          * keep the reference count > 0.
136          */
137         dasd_get_device(device);
138
139         rc = dasd_alloc_queue(device);
140         if (rc) {
141                 dasd_put_device(device);
142                 return rc;
143         }
144
145         device->state = DASD_STATE_KNOWN;
146         return 0;
147 }
148
149 /*
150  * Let the system forget about a device.
151  */
152 static inline void
153 dasd_state_known_to_new(struct dasd_device * device)
154 {
155         /* Forget the discipline information. */
156         device->discipline = NULL;
157         device->state = DASD_STATE_NEW;
158
159         dasd_free_queue(device);
160
161         /* Give up reference we took in dasd_state_new_to_known. */
162         dasd_put_device(device);
163 }
164
165 /*
166  * Request the irq line for the device.
167  */
168 static inline int
169 dasd_state_known_to_basic(struct dasd_device * device)
170 {
171         int rc;
172
173         /* Allocate and register gendisk structure. */
174         rc = dasd_gendisk_alloc(device);
175         if (rc)
176                 return rc;
177
178         /* register 'device' debug area, used for all DBF_DEV_XXX calls */
179         device->debug_area = debug_register(device->cdev->dev.bus_id, 0, 2,
180                                             8 * sizeof (long));
181         debug_register_view(device->debug_area, &debug_sprintf_view);
182         debug_set_level(device->debug_area, DBF_ERR);
183         DBF_DEV_EVENT(DBF_EMERG, device, "%s", "debug area created");
184
185         device->state = DASD_STATE_BASIC;
186         return 0;
187 }
188
189 /*
190  * Release the irq line for the device. Terminate any running i/o.
191  */
192 static inline void
193 dasd_state_basic_to_known(struct dasd_device * device)
194 {
195         dasd_gendisk_free(device);
196         dasd_flush_ccw_queue(device, 1);
197         DBF_DEV_EVENT(DBF_EMERG, device, "%p debug area deleted", device);
198         if (device->debug_area != NULL) {
199                 debug_unregister(device->debug_area);
200                 device->debug_area = NULL;
201         }
202         device->state = DASD_STATE_KNOWN;
203 }
204
205 /*
206  * Do the initial analysis. The do_analysis function may return
207  * -EAGAIN in which case the device keeps the state DASD_STATE_BASIC
208  * until the discipline decides to continue the startup sequence
209  * by calling the function dasd_change_state. The eckd disciplines
210  * uses this to start a ccw that detects the format. The completion
211  * interrupt for this detection ccw uses the kernel event daemon to
212  * trigger the call to dasd_change_state. All this is done in the
213  * discipline code, see dasd_eckd.c.
214  * After the analysis ccw is done (do_analysis returned 0 or error)
215  * the block device is setup. Either a fake disk is added to allow
216  * formatting or a proper device request queue is created.
217  */
218 static inline int
219 dasd_state_basic_to_ready(struct dasd_device * device)
220 {
221         int rc;
222
223         rc = 0;
224         if (device->discipline->do_analysis != NULL)
225                 rc = device->discipline->do_analysis(device);
226         if (rc)
227                 return rc;
228         dasd_setup_queue(device);
229         device->state = DASD_STATE_READY;
230         if (dasd_scan_partitions(device) != 0)
231                 device->state = DASD_STATE_BASIC;
232         return 0;
233 }
234
235 /*
236  * Remove device from block device layer. Destroy dirty buffers.
237  * Forget format information. Check if the target level is basic
238  * and if it is create fake disk for formatting.
239  */
240 static inline void
241 dasd_state_ready_to_basic(struct dasd_device * device)
242 {
243         dasd_flush_ccw_queue(device, 0);
244         dasd_destroy_partitions(device);
245         dasd_flush_request_queue(device);
246         device->blocks = 0;
247         device->bp_block = 0;
248         device->s2b_shift = 0;
249         device->state = DASD_STATE_BASIC;
250 }
251
252 /*
253  * Make the device online and schedule the bottom half to start
254  * the requeueing of requests from the linux request queue to the
255  * ccw queue.
256  */
257 static inline int
258 dasd_state_ready_to_online(struct dasd_device * device)
259 {
260         device->state = DASD_STATE_ONLINE;
261         dasd_schedule_bh(device);
262         return 0;
263 }
264
265 /*
266  * Stop the requeueing of requests again.
267  */
268 static inline void
269 dasd_state_online_to_ready(struct dasd_device * device)
270 {
271         device->state = DASD_STATE_READY;
272 }
273
274 /*
275  * Device startup state changes.
276  */
277 static inline int
278 dasd_increase_state(struct dasd_device *device)
279 {
280         int rc;
281
282         rc = 0;
283         if (device->state == DASD_STATE_NEW &&
284             device->target >= DASD_STATE_KNOWN)
285                 rc = dasd_state_new_to_known(device);
286
287         if (!rc &&
288             device->state == DASD_STATE_KNOWN &&
289             device->target >= DASD_STATE_BASIC)
290                 rc = dasd_state_known_to_basic(device);
291
292         if (!rc &&
293             device->state == DASD_STATE_BASIC &&
294             device->target >= DASD_STATE_READY)
295                 rc = dasd_state_basic_to_ready(device);
296
297         if (!rc &&
298             device->state == DASD_STATE_READY &&
299             device->target >= DASD_STATE_ONLINE)
300                 rc = dasd_state_ready_to_online(device);
301
302         return rc;
303 }
304
305 /*
306  * Device shutdown state changes.
307  */
308 static inline int
309 dasd_decrease_state(struct dasd_device *device)
310 {
311         if (device->state == DASD_STATE_ONLINE &&
312             device->target <= DASD_STATE_READY)
313                 dasd_state_online_to_ready(device);
314         
315         if (device->state == DASD_STATE_READY &&
316             device->target <= DASD_STATE_BASIC)
317                 dasd_state_ready_to_basic(device);
318         
319         if (device->state == DASD_STATE_BASIC && 
320             device->target <= DASD_STATE_KNOWN)
321                 dasd_state_basic_to_known(device);
322         
323         if (device->state == DASD_STATE_KNOWN &&
324             device->target <= DASD_STATE_NEW)
325                 dasd_state_known_to_new(device);
326
327         return 0;
328 }
329
330 /*
331  * This is the main startup/shutdown routine.
332  */
333 static void
334 dasd_change_state(struct dasd_device *device)
335 {
336         int rc;
337
338         if (device->state == device->target)
339                 /* Already where we want to go today... */
340                 return;
341         if (device->state < device->target)
342                 rc = dasd_increase_state(device);
343         else
344                 rc = dasd_decrease_state(device);
345         if (rc && rc != -EAGAIN)
346                 device->target = device->state;
347
348         if (device->state == device->target)
349                 wake_up(&dasd_init_waitq);
350 }
351
352 /*
353  * Kick starter for devices that did not complete the startup/shutdown
354  * procedure or were sleeping because of a pending state.
355  * dasd_kick_device will schedule a call do do_kick_device to the kernel
356  * event daemon.
357  */
358 static void
359 do_kick_device(void *data)
360 {
361         struct dasd_device *device;
362
363         device = (struct dasd_device *) data;
364         dasd_change_state(device);
365         dasd_schedule_bh(device);
366         dasd_put_device(device);
367 }
368
369 void
370 dasd_kick_device(struct dasd_device *device)
371 {
372         dasd_get_device(device);
373         /* queue call to dasd_kick_device to the kernel event daemon. */
374         schedule_work(&device->kick_work);
375 }
376
377 /*
378  * Set the target state for a device and starts the state change.
379  */
380 void
381 dasd_set_target_state(struct dasd_device *device, int target)
382 {
383         /* If we are in probeonly mode stop at DASD_STATE_READY. */
384         if (dasd_probeonly && target > DASD_STATE_READY)
385                 target = DASD_STATE_READY;
386         if (device->target != target) {
387                 if (device->state == target)
388                         wake_up(&dasd_init_waitq);
389                 device->target = target;
390         }
391         if (device->state != device->target)
392                 dasd_change_state(device);
393 }
394
395 /*
396  * Enable devices with device numbers in [from..to].
397  */
398 static inline int
399 _wait_for_device(struct dasd_device *device)
400 {
401         return (device->state == device->target);
402 }
403
404 void
405 dasd_enable_device(struct dasd_device *device)
406 {
407         dasd_set_target_state(device, DASD_STATE_ONLINE);
408         if (device->state <= DASD_STATE_KNOWN)
409                 /* No discipline for device found. */
410                 dasd_set_target_state(device, DASD_STATE_NEW);
411         /* Now wait for the devices to come up. */
412         wait_event(dasd_init_waitq, _wait_for_device(device));
413 }
414
415 /*
416  * SECTION: device operation (interrupt handler, start i/o, term i/o ...)
417  */
418 #ifdef CONFIG_DASD_PROFILE
419
420 struct dasd_profile_info_t dasd_global_profile;
421 unsigned int dasd_profile_level = DASD_PROFILE_OFF;
422
423 /*
424  * Increments counter in global and local profiling structures.
425  */
426 #define dasd_profile_counter(value, counter, device) \
427 { \
428         int index; \
429         for (index = 0; index < 31 && value >> (2+index); index++); \
430         dasd_global_profile.counter[index]++; \
431         device->profile.counter[index]++; \
432 }
433
434 /*
435  * Add profiling information for cqr before execution.
436  */
437 static inline void
438 dasd_profile_start(struct dasd_device *device, struct dasd_ccw_req * cqr,
439                    struct request *req)
440 {
441         struct list_head *l;
442         unsigned int counter;
443
444         if (dasd_profile_level != DASD_PROFILE_ON)
445                 return;
446
447         /* count the length of the chanq for statistics */
448         counter = 0;
449         list_for_each(l, &device->ccw_queue)
450                 if (++counter >= 31)
451                         break;
452         dasd_global_profile.dasd_io_nr_req[counter]++;
453         device->profile.dasd_io_nr_req[counter]++;
454 }
455
456 /*
457  * Add profiling information for cqr after execution.
458  */
459 static inline void
460 dasd_profile_end(struct dasd_device *device, struct dasd_ccw_req * cqr,
461                  struct request *req)
462 {
463         long strtime, irqtime, endtime, tottime;        /* in microseconds */
464         long tottimeps, sectors;
465
466         if (dasd_profile_level != DASD_PROFILE_ON)
467                 return;
468
469         sectors = req->nr_sectors;
470         if (!cqr->buildclk || !cqr->startclk ||
471             !cqr->stopclk || !cqr->endclk ||
472             !sectors)
473                 return;
474
475         strtime = ((cqr->startclk - cqr->buildclk) >> 12);
476         irqtime = ((cqr->stopclk - cqr->startclk) >> 12);
477         endtime = ((cqr->endclk - cqr->stopclk) >> 12);
478         tottime = ((cqr->endclk - cqr->buildclk) >> 12);
479         tottimeps = tottime / sectors;
480
481         if (!dasd_global_profile.dasd_io_reqs)
482                 memset(&dasd_global_profile, 0,
483                        sizeof (struct dasd_profile_info_t));
484         dasd_global_profile.dasd_io_reqs++;
485         dasd_global_profile.dasd_io_sects += sectors;
486
487         if (!device->profile.dasd_io_reqs)
488                 memset(&device->profile, 0,
489                        sizeof (struct dasd_profile_info_t));
490         device->profile.dasd_io_reqs++;
491         device->profile.dasd_io_sects += sectors;
492
493         dasd_profile_counter(sectors, dasd_io_secs, device);
494         dasd_profile_counter(tottime, dasd_io_times, device);
495         dasd_profile_counter(tottimeps, dasd_io_timps, device);
496         dasd_profile_counter(strtime, dasd_io_time1, device);
497         dasd_profile_counter(irqtime, dasd_io_time2, device);
498         dasd_profile_counter(irqtime / sectors, dasd_io_time2ps, device);
499         dasd_profile_counter(endtime, dasd_io_time3, device);
500 }
501 #else
502 #define dasd_profile_start(device, cqr, req) do {} while (0)
503 #define dasd_profile_end(device, cqr, req) do {} while (0)
504 #endif                          /* CONFIG_DASD_PROFILE */
505
506 /*
507  * Allocate memory for a channel program with 'cplength' channel
508  * command words and 'datasize' additional space. There are two
509  * variantes: 1) dasd_kmalloc_request uses kmalloc to get the needed
510  * memory and 2) dasd_smalloc_request uses the static ccw memory
511  * that gets allocated for each device.
512  */
513 struct dasd_ccw_req *
514 dasd_kmalloc_request(char *magic, int cplength, int datasize,
515                    struct dasd_device * device)
516 {
517         struct dasd_ccw_req *cqr;
518
519         /* Sanity checks */
520         if ( magic == NULL || datasize > PAGE_SIZE ||
521              (cplength*sizeof(struct ccw1)) > PAGE_SIZE)
522                 BUG();
523         debug_text_event ( dasd_debug_area, 1, "ALLC");
524         debug_text_event ( dasd_debug_area, 1, magic);
525         debug_int_event ( dasd_debug_area, 1, cplength);
526         debug_int_event ( dasd_debug_area, 1, datasize);
527
528         cqr = kmalloc(sizeof(struct dasd_ccw_req), GFP_ATOMIC);
529         if (cqr == NULL)
530                 return ERR_PTR(-ENOMEM);
531         memset(cqr, 0, sizeof(struct dasd_ccw_req));
532         cqr->cpaddr = NULL;
533         if (cplength > 0) {
534                 cqr->cpaddr = kmalloc(cplength*sizeof(struct ccw1),
535                                       GFP_ATOMIC | GFP_DMA);
536                 if (cqr->cpaddr == NULL) {
537                         kfree(cqr);
538                         return ERR_PTR(-ENOMEM);
539                 }
540                 memset(cqr->cpaddr, 0, cplength*sizeof(struct ccw1));
541         }
542         cqr->data = NULL;
543         if (datasize > 0) {
544                 cqr->data = kmalloc(datasize, GFP_ATOMIC | GFP_DMA);
545                 if (cqr->data == NULL) {
546                         if (cqr->cpaddr != NULL)
547                                 kfree(cqr->cpaddr);
548                         kfree(cqr);
549                         return ERR_PTR(-ENOMEM);
550                 }
551                 memset(cqr->data, 0, datasize);
552         }
553         strncpy((char *) &cqr->magic, magic, 4);
554         ASCEBC((char *) &cqr->magic, 4);
555         set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
556         dasd_get_device(device);
557         return cqr;
558 }
559
560 struct dasd_ccw_req *
561 dasd_smalloc_request(char *magic, int cplength, int datasize,
562                    struct dasd_device * device)
563 {
564         unsigned long flags;
565         struct dasd_ccw_req *cqr;
566         char *data;
567         int size;
568
569         /* Sanity checks */
570         if ( magic == NULL || datasize > PAGE_SIZE ||
571              (cplength*sizeof(struct ccw1)) > PAGE_SIZE)
572                 BUG();
573         debug_text_event ( dasd_debug_area, 1, "ALLC");
574         debug_text_event ( dasd_debug_area, 1, magic);
575         debug_int_event ( dasd_debug_area, 1, cplength);
576         debug_int_event ( dasd_debug_area, 1, datasize);
577
578         size = (sizeof(struct dasd_ccw_req) + 7L) & -8L;
579         if (cplength > 0)
580                 size += cplength * sizeof(struct ccw1);
581         if (datasize > 0)
582                 size += datasize;
583         spin_lock_irqsave(&device->mem_lock, flags);
584         cqr = (struct dasd_ccw_req *)
585                 dasd_alloc_chunk(&device->ccw_chunks, size);
586         spin_unlock_irqrestore(&device->mem_lock, flags);
587         if (cqr == NULL)
588                 return ERR_PTR(-ENOMEM);
589         memset(cqr, 0, sizeof(struct dasd_ccw_req));
590         data = (char *) cqr + ((sizeof(struct dasd_ccw_req) + 7L) & -8L);
591         cqr->cpaddr = NULL;
592         if (cplength > 0) {
593                 cqr->cpaddr = (struct ccw1 *) data;
594                 data += cplength*sizeof(struct ccw1);
595                 memset(cqr->cpaddr, 0, cplength*sizeof(struct ccw1));
596         }
597         cqr->data = NULL;
598         if (datasize > 0) {
599                 cqr->data = data;
600                 memset(cqr->data, 0, datasize);
601         }
602         strncpy((char *) &cqr->magic, magic, 4);
603         ASCEBC((char *) &cqr->magic, 4);
604         set_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
605         dasd_get_device(device);
606         return cqr;
607 }
608
609 /*
610  * Free memory of a channel program. This function needs to free all the
611  * idal lists that might have been created by dasd_set_cda and the
612  * struct dasd_ccw_req itself.
613  */
614 void
615 dasd_kfree_request(struct dasd_ccw_req * cqr, struct dasd_device * device)
616 {
617 #ifdef CONFIG_ARCH_S390X
618         struct ccw1 *ccw;
619
620         /* Clear any idals used for the request. */
621         ccw = cqr->cpaddr;
622         do {
623                 clear_normalized_cda(ccw);
624         } while (ccw++->flags & (CCW_FLAG_CC | CCW_FLAG_DC));
625 #endif
626         if (cqr->dstat != NULL)
627                 kfree(cqr->dstat);
628         debug_text_event ( dasd_debug_area, 1, "FREE");
629         debug_int_event ( dasd_debug_area, 1, (long) cqr);
630         if (cqr->cpaddr != NULL)
631                 kfree(cqr->cpaddr);
632         if (cqr->data != NULL)
633                 kfree(cqr->data);
634         kfree(cqr);
635         dasd_put_device(device);
636 }
637
638 void
639 dasd_sfree_request(struct dasd_ccw_req * cqr, struct dasd_device * device)
640 {
641         unsigned long flags;
642
643         if (cqr->dstat != NULL)
644                 kfree(cqr->dstat);
645         debug_text_event(dasd_debug_area, 1, "FREE");
646         debug_int_event(dasd_debug_area, 1, (long) cqr);
647         spin_lock_irqsave(&device->mem_lock, flags);
648         dasd_free_chunk(&device->ccw_chunks, cqr);
649         spin_unlock_irqrestore(&device->mem_lock, flags);
650         dasd_put_device(device);
651 }
652
653 /*
654  * Check discipline magic in cqr.
655  */
656 static inline int
657 dasd_check_cqr(struct dasd_ccw_req *cqr)
658 {
659         struct dasd_device *device;
660
661         if (cqr == NULL)
662                 return -EINVAL;
663         device = cqr->device;
664         if (strncmp((char *) &cqr->magic, device->discipline->ebcname, 4)) {
665                 DEV_MESSAGE(KERN_WARNING, device,
666                             " dasd_ccw_req 0x%08x magic doesn't match"
667                             " discipline 0x%08x",
668                             cqr->magic,
669                             *(unsigned int *) device->discipline->name);
670                 return -EINVAL;
671         }
672         return 0;
673 }
674
675 /*
676  * Terminate the current i/o and set the request to failed.
677  * ccw_device_clear can fail if the i/o subsystem
678  * is in a bad mood.
679  */
680 int
681 dasd_term_IO(struct dasd_ccw_req * cqr)
682 {
683         struct dasd_device *device;
684         int retries, rc;
685
686         /* Check the cqr */
687         rc = dasd_check_cqr(cqr);
688         if (rc)
689                 return rc;
690         retries = 0;
691         device = (struct dasd_device *) cqr->device;
692         while ((retries < 5) && (cqr->status == DASD_CQR_IN_IO)) {
693                 rc = ccw_device_clear(device->cdev, (long) cqr);
694                 switch (rc) {
695                 case 0: /* termination successful */
696                         if (cqr->retries > 0) {
697                                 cqr->retries--;
698                                 cqr->status = DASD_CQR_QUEUED;
699                         } else
700                                 cqr->status = DASD_CQR_FAILED;
701                         cqr->stopclk = get_clock();
702                         break;
703                 case -ENODEV:
704                         DBF_DEV_EVENT(DBF_ERR, device, "%s",
705                                       "device gone, retry");
706                         break;
707                 case -EIO:
708                         DBF_DEV_EVENT(DBF_ERR, device, "%s",
709                                       "I/O error, retry");
710                         break;
711                 case -EINVAL:
712                 case -EBUSY:
713                         DBF_DEV_EVENT(DBF_ERR, device, "%s",
714                                       "device busy, retry later");
715                         break;
716                 default:
717                         DEV_MESSAGE(KERN_ERR, device,
718                                     "line %d unknown RC=%d, please "
719                                     "report to linux390@de.ibm.com",
720                                     __LINE__, rc);
721                         BUG();
722                         break;
723                 }
724                 retries++;
725         }
726         dasd_schedule_bh(device);
727         return rc;
728 }
729
730 /*
731  * Start the i/o. This start_IO can fail if the channel is really busy.
732  * In that case set up a timer to start the request later.
733  */
734 int
735 dasd_start_IO(struct dasd_ccw_req * cqr)
736 {
737         struct dasd_device *device;
738         int rc;
739
740         /* Check the cqr */
741         rc = dasd_check_cqr(cqr);
742         if (rc)
743                 return rc;
744         device = (struct dasd_device *) cqr->device;
745         cqr->startclk = get_clock();
746         cqr->starttime = jiffies;
747         rc = ccw_device_start(device->cdev, cqr->cpaddr, (long) cqr,
748                               cqr->lpm, 0);
749         switch (rc) {
750         case 0:
751                 cqr->status = DASD_CQR_IN_IO;
752                 break;
753         case -EBUSY:
754                 DBF_DEV_EVENT(DBF_ERR, device, "%s",
755                               "start_IO: device busy, retry later");
756                 break;
757         case -ETIMEDOUT:
758                 DBF_DEV_EVENT(DBF_ERR, device, "%s",
759                               "start_IO: request timeout, retry later");
760                 break;
761         case -ENODEV:
762         case -EIO:
763                 DBF_DEV_EVENT(DBF_ERR, device, "%s",
764                               "start_IO: device gone, retry");
765                 break;
766         default:
767                 DEV_MESSAGE(KERN_ERR, device,
768                             "line %d unknown RC=%d, please report"
769                             " to linux390@de.ibm.com", __LINE__, rc);
770                 BUG();
771                 break;
772         }
773         return rc;
774 }
775
776 /*
777  * Timeout function for dasd devices. This is used for different purposes
778  *  1) missing interrupt handler for normal operation
779  *  2) delayed start of request where start_IO failed with -EBUSY
780  *  3) timeout for missing state change interrupts
781  * The head of the ccw queue will have status DASD_CQR_IN_IO for 1),
782  * DASD_CQR_QUEUED for 2) and 3).
783  */
784 static void
785 dasd_timeout_device(unsigned long ptr)
786 {
787         unsigned long flags;
788         struct dasd_device *device;
789
790         device = (struct dasd_device *) ptr;
791         spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
792         /* re-activate request queue */
793         device->stopped &= ~DASD_STOPPED_PENDING;
794         spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
795         dasd_schedule_bh(device);
796 }
797
798 /*
799  * Setup timeout for a device in jiffies.
800  */
801 void
802 dasd_set_timer(struct dasd_device *device, int expires)
803 {
804         if (expires == 0) {
805                 if (timer_pending(&device->timer))
806                         del_timer(&device->timer);
807                 return;
808         }
809         if (timer_pending(&device->timer)) {
810                 if (mod_timer(&device->timer, jiffies + expires))
811                         return;
812         }
813         device->timer.function = dasd_timeout_device;
814         device->timer.data = (unsigned long) device;
815         device->timer.expires = jiffies + expires;
816         add_timer(&device->timer);
817 }
818
819 /*
820  * Clear timeout for a device.
821  */
822 void
823 dasd_clear_timer(struct dasd_device *device)
824 {
825         if (timer_pending(&device->timer))
826                 del_timer(&device->timer);
827 }
828
829 /*
830  *   Handles the state change pending interrupt.
831  */
832 static void
833 do_state_change_pending(void *data)
834 {
835         struct {
836                 struct work_struct work;
837                 struct dasd_device *device;
838         } *p;
839         struct dasd_device *device;
840         struct dasd_ccw_req *cqr;
841         struct list_head *l, *n;
842         unsigned long flags;
843
844         p = data;
845         device = p->device;
846         DBF_EVENT(DBF_NOTICE, "State change Interrupt for bus_id %s",
847                   device->cdev->dev.bus_id);
848         device->stopped &= ~DASD_STOPPED_PENDING;
849
850         /* restart all 'running' IO on queue */
851         spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
852         list_for_each_safe(l, n, &device->ccw_queue) {
853                 cqr = list_entry(l, struct dasd_ccw_req, list);
854                 if (cqr->status == DASD_CQR_IN_IO)
855                         cqr->status = DASD_CQR_QUEUED;
856         }
857         spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
858         dasd_set_timer (device, 0);
859         dasd_schedule_bh(device);
860         dasd_put_device(device);
861         kfree(p);
862 }
863
864 static void
865 dasd_handle_killed_request(struct ccw_device *cdev, unsigned long intparm)
866 {
867         struct dasd_ccw_req *cqr;
868         struct dasd_device *device;
869
870         cqr = (struct dasd_ccw_req *) intparm;
871         if (cqr->status != DASD_CQR_IN_IO) {
872                 MESSAGE(KERN_DEBUG,
873                         "invalid status in handle_killed_request: "
874                         "bus_id %s, status %02x",
875                         cdev->dev.bus_id, cqr->status);
876                 return;
877         }
878
879         device = (struct dasd_device *) cqr->device;
880         if (device == NULL ||
881             device != dasd_device_from_cdev(cdev) ||
882             strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) {
883                 MESSAGE(KERN_DEBUG, "invalid device in request: bus_id %s",
884                         cdev->dev.bus_id);
885                 return;
886         }
887
888         /* Schedule request to be retried. */
889         cqr->status = DASD_CQR_QUEUED;
890
891         dasd_clear_timer(device);
892         dasd_schedule_bh(device);
893         dasd_put_device(device);
894 }
895
896 static void
897 dasd_handle_state_change_pending(struct dasd_device *device)
898 {
899         struct {
900                 struct work_struct work;
901                 struct dasd_device *device;
902         } *p;
903
904         p = kmalloc(sizeof(*p), GFP_ATOMIC);
905         if (p == NULL)
906                 /* No memory, let the timeout do the reactivation. */
907                 return;
908         INIT_WORK(&p->work, (void *) do_state_change_pending, p);
909         p->device = device;
910         dasd_get_device(device);
911         schedule_work(&p->work);
912 }
913
914 /*
915  * Interrupt handler for "normal" ssch-io based dasd devices.
916  */
917 void
918 dasd_int_handler(struct ccw_device *cdev, unsigned long intparm,
919                  struct irb *irb)
920 {
921         struct dasd_ccw_req *cqr, *next;
922         struct dasd_device *device;
923         unsigned long long now;
924         int expires;
925         dasd_era_t era;
926         char mask;
927
928         if (IS_ERR(irb)) {
929                 switch (PTR_ERR(irb)) {
930                 case -EIO:
931                         dasd_handle_killed_request(cdev, intparm);
932                         break;
933                 case -ETIMEDOUT:
934                         printk(KERN_WARNING"%s(%s): request timed out\n",
935                                __FUNCTION__, cdev->dev.bus_id);
936                         //FIXME - dasd uses own timeout interface...
937                         break;
938                 default:
939                         printk(KERN_WARNING"%s(%s): unknown error %ld\n",
940                                __FUNCTION__, cdev->dev.bus_id, PTR_ERR(irb));
941                 }
942                 return;
943         }
944
945         now = get_clock();
946
947         DBF_EVENT(DBF_DEBUG, "Interrupt: stat %02x, bus_id %s",
948                   irb->scsw.dstat, cdev->dev.bus_id);
949
950         /* first of all check for state change pending interrupt */
951         mask = DEV_STAT_ATTENTION | DEV_STAT_DEV_END | DEV_STAT_UNIT_EXCEP;
952         if ((irb->scsw.dstat & mask) == mask) {
953                 device = dasd_device_from_cdev(cdev);
954                 if (!IS_ERR(device)) {
955                         dasd_handle_state_change_pending(device);
956                         dasd_put_device(device);
957                 }
958                 return;
959         }
960
961         cqr = (struct dasd_ccw_req *) intparm;
962         /*
963          * check status - the request might have been killed
964          * because of dyn detach
965          */
966         if (cqr->status != DASD_CQR_IN_IO) {
967                 MESSAGE(KERN_DEBUG,
968                         "invalid status: bus_id %s, status %02x",
969                         cdev->dev.bus_id, cqr->status);
970                 return;
971         }
972
973         device = (struct dasd_device *) cqr->device;
974         if (device == NULL ||
975             strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) {
976                 MESSAGE(KERN_DEBUG, "invalid device in request: bus_id %s",
977                         cdev->dev.bus_id);
978                 return;
979         }
980
981         DBF_DEV_EVENT(DBF_DEBUG, device, "Int: CS/DS 0x%04x",
982                       ((irb->scsw.cstat << 8) | irb->scsw.dstat));
983
984         /* Find out the appropriate era_action. */
985         if (irb->scsw.fctl & SCSW_FCTL_HALT_FUNC) 
986                 era = dasd_era_fatal;
987         else if (irb->scsw.dstat == (DEV_STAT_CHN_END | DEV_STAT_DEV_END) &&
988                  irb->scsw.cstat == 0 &&
989                  !irb->esw.esw0.erw.cons)
990                 era = dasd_era_none;
991         else if (!test_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags))
992                 era = dasd_era_fatal; /* don't recover this request */
993         else if (irb->esw.esw0.erw.cons)
994                 era = device->discipline->examine_error(cqr, irb);
995         else 
996                 era = dasd_era_recover;
997
998         DBF_DEV_EVENT(DBF_DEBUG, device, "era_code %d", era);
999         expires = 0;
1000         if (era == dasd_era_none) {
1001                 cqr->status = DASD_CQR_DONE;
1002                 cqr->stopclk = now;
1003                 /* Start first request on queue if possible -> fast_io. */
1004                 if (cqr->list.next != &device->ccw_queue) {
1005                         next = list_entry(cqr->list.next,
1006                                           struct dasd_ccw_req, list);
1007                         if ((next->status == DASD_CQR_QUEUED) &&
1008                             (!device->stopped)) {
1009                                 if (device->discipline->start_IO(next) == 0)
1010                                         expires = next->expires;
1011                                 else
1012                                         DEV_MESSAGE(KERN_DEBUG, device, "%s",
1013                                                     "Interrupt fastpath "
1014                                                     "failed!");
1015                         }
1016                 }
1017         } else {                /* error */
1018                 if (cqr->dstat == NULL)
1019                         cqr->dstat = kmalloc(sizeof(struct irb), GFP_ATOMIC);
1020                 if (cqr->dstat)
1021                         memcpy(cqr->dstat, irb, sizeof (struct irb));
1022                 else
1023                         DEV_MESSAGE(KERN_ERR, device, "%s",
1024                                     "no memory for dstat...ignoring");
1025 #ifdef ERP_DEBUG
1026                 /* dump sense data */
1027                 dasd_log_sense(cqr, irb);
1028 #endif
1029                 switch (era) {
1030                 case dasd_era_fatal:
1031                         cqr->status = DASD_CQR_FAILED;
1032                         cqr->stopclk = now;
1033                         break;
1034                 case dasd_era_recover:
1035                         cqr->status = DASD_CQR_ERROR;
1036                         break;
1037                 default:
1038                         BUG();
1039                 }
1040         }
1041         if (expires != 0)
1042                 dasd_set_timer(device, expires);
1043         else
1044                 dasd_clear_timer(device);
1045         dasd_schedule_bh(device);
1046 }
1047
1048 /*
1049  * posts the buffer_cache about a finalized request
1050  */
1051 static inline void
1052 dasd_end_request(struct request *req, int uptodate)
1053 {
1054         if (end_that_request_first(req, uptodate, req->hard_nr_sectors))
1055                 BUG();
1056         add_disk_randomness(req->rq_disk);
1057         end_that_request_last(req);
1058 }
1059
1060 /*
1061  * Process finished error recovery ccw.
1062  */
1063 static inline void
1064 __dasd_process_erp(struct dasd_device *device, struct dasd_ccw_req *cqr)
1065 {
1066         dasd_erp_fn_t erp_fn;
1067
1068         if (cqr->status == DASD_CQR_DONE)
1069                 DBF_DEV_EVENT(DBF_NOTICE, device, "%s", "ERP successful");
1070         else
1071                 DEV_MESSAGE(KERN_ERR, device, "%s", "ERP unsuccessful");
1072         erp_fn = device->discipline->erp_postaction(cqr);
1073         erp_fn(cqr);
1074 }
1075
1076 /*
1077  * Process ccw request queue.
1078  */
1079 static inline void
1080 __dasd_process_ccw_queue(struct dasd_device * device,
1081                          struct list_head *final_queue)
1082 {
1083         struct list_head *l, *n;
1084         struct dasd_ccw_req *cqr;
1085         dasd_erp_fn_t erp_fn;
1086
1087 restart:
1088         /* Process request with final status. */
1089         list_for_each_safe(l, n, &device->ccw_queue) {
1090                 cqr = list_entry(l, struct dasd_ccw_req, list);
1091                 /* Stop list processing at the first non-final request. */
1092                 if (cqr->status != DASD_CQR_DONE &&
1093                     cqr->status != DASD_CQR_FAILED &&
1094                     cqr->status != DASD_CQR_ERROR)
1095                         break;
1096                 /*  Process requests with DASD_CQR_ERROR */
1097                 if (cqr->status == DASD_CQR_ERROR) {
1098                         cqr->retries--;
1099                         if (cqr->dstat->scsw.fctl & SCSW_FCTL_HALT_FUNC) {
1100                                 cqr->status = DASD_CQR_FAILED;
1101                                 cqr->stopclk = get_clock();
1102                         } else {
1103                                 if (cqr->dstat->esw.esw0.erw.cons) {
1104                                         erp_fn = device->discipline->erp_action(cqr);
1105                                         erp_fn(cqr);
1106                                 } else
1107                                         dasd_default_erp_action(cqr);
1108                         }
1109                         goto restart;
1110                 }
1111                 /* Process finished ERP request. */
1112                 if (cqr->refers) {
1113                         __dasd_process_erp(device, cqr);
1114                         goto restart;
1115                 }
1116
1117                 /* Rechain finished requests to final queue */
1118                 cqr->endclk = get_clock();
1119                 list_move_tail(&cqr->list, final_queue);
1120         }
1121 }
1122
1123 static void
1124 dasd_end_request_cb(struct dasd_ccw_req * cqr, void *data)
1125 {
1126         struct request *req;
1127
1128         req = (struct request *) data;
1129         dasd_profile_end(cqr->device, cqr, req);
1130         spin_lock_irq(&cqr->device->request_queue_lock);
1131         dasd_end_request(req, (cqr->status == DASD_CQR_DONE));
1132         spin_unlock_irq(&cqr->device->request_queue_lock);
1133         dasd_sfree_request(cqr, cqr->device);
1134 }
1135
1136
1137 /*
1138  * Fetch requests from the block device queue.
1139  */
1140 static inline void
1141 __dasd_process_blk_queue(struct dasd_device * device)
1142 {
1143         request_queue_t *queue;
1144         struct request *req;
1145         struct dasd_ccw_req *cqr;
1146         int nr_queued;
1147
1148         queue = device->request_queue;
1149         /* No queue ? Then there is nothing to do. */
1150         if (queue == NULL)
1151                 return;
1152
1153         /*
1154          * We requeue request from the block device queue to the ccw
1155          * queue only in two states. In state DASD_STATE_READY the
1156          * partition detection is done and we need to requeue requests
1157          * for that. State DASD_STATE_ONLINE is normal block device
1158          * operation.
1159          */
1160         if (device->state != DASD_STATE_READY &&
1161             device->state != DASD_STATE_ONLINE)
1162                 return;
1163         nr_queued = 0;
1164         /* Now we try to fetch requests from the request queue */
1165         list_for_each_entry(cqr, &device->ccw_queue, list)
1166                 if (cqr->status == DASD_CQR_QUEUED)
1167                         nr_queued++;
1168         while (!blk_queue_plugged(queue) &&
1169                elv_next_request(queue) &&
1170                 nr_queued < DASD_CHANQ_MAX_SIZE) {
1171                 req = elv_next_request(queue);
1172                 if (test_bit(DASD_FLAG_RO, &device->flags) &&
1173                     rq_data_dir(req) == WRITE) {
1174                         DBF_EVENT(DBF_ERR,
1175                                   "(%s) Rejecting write request %p",
1176                                   device->cdev->dev.bus_id,
1177                                   req);
1178                         blkdev_dequeue_request(req);
1179                         dasd_end_request(req, 0);
1180                         continue;
1181                 }
1182                 if (device->stopped & DASD_STOPPED_DC_EIO) {
1183                         blkdev_dequeue_request(req);
1184                         dasd_end_request(req, 0);
1185                         continue;
1186                 }
1187                 cqr = device->discipline->build_cp(device, req);
1188                 if (IS_ERR(cqr)) {
1189                         if (PTR_ERR(cqr) == -ENOMEM)
1190                                 break;  /* terminate request queue loop */
1191                         DBF_EVENT(DBF_ERR,
1192                                   "(%s) CCW creation failed on request %p",
1193                                   device->cdev->dev.bus_id,
1194                                   req);
1195                         blkdev_dequeue_request(req);
1196                         dasd_end_request(req, 0);
1197                         continue;
1198                 }
1199                 cqr->callback = dasd_end_request_cb;
1200                 cqr->callback_data = (void *) req;
1201                 cqr->status = DASD_CQR_QUEUED;
1202                 blkdev_dequeue_request(req);
1203                 list_add_tail(&cqr->list, &device->ccw_queue);
1204                 dasd_profile_start(device, cqr, req);
1205                 nr_queued++;
1206         }
1207 }
1208
1209 /*
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.
1212  */
1213 static inline void
1214 __dasd_check_expire(struct dasd_device * device)
1215 {
1216         struct dasd_ccw_req *cqr;
1217
1218         if (list_empty(&device->ccw_queue))
1219                 return;
1220         cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list);
1221         if (cqr->status == DASD_CQR_IN_IO && cqr->expires != 0) {
1222                 if (time_after_eq(jiffies, cqr->expires + cqr->starttime)) {
1223                         if (device->discipline->term_IO(cqr) != 0)
1224                                 /* Hmpf, try again in 1/100 sec */
1225                                 dasd_set_timer(device, 1);
1226                 }
1227         }
1228 }
1229
1230 /*
1231  * Take a look at the first request on the ccw queue and check
1232  * if it needs to be started.
1233  */
1234 static inline void
1235 __dasd_start_head(struct dasd_device * device)
1236 {
1237         struct dasd_ccw_req *cqr;
1238         int rc;
1239
1240         if (list_empty(&device->ccw_queue))
1241                 return;
1242         cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list);
1243         if ((cqr->status == DASD_CQR_QUEUED) &&
1244             (!device->stopped)) {
1245                 /* try to start the first I/O that can be started */
1246                 rc = device->discipline->start_IO(cqr);
1247                 if (rc == 0)
1248                         dasd_set_timer(device, cqr->expires);
1249                 else if (rc == -EBUSY)
1250                                 /* Hmpf, try again in 1/100 sec */
1251                         dasd_set_timer(device, 1);
1252         }
1253 }
1254
1255 /*
1256  * Remove requests from the ccw queue. 
1257  */
1258 static void
1259 dasd_flush_ccw_queue(struct dasd_device * device, int all)
1260 {
1261         struct list_head flush_queue;
1262         struct list_head *l, *n;
1263         struct dasd_ccw_req *cqr;
1264
1265         INIT_LIST_HEAD(&flush_queue);
1266         spin_lock_irq(get_ccwdev_lock(device->cdev));
1267         list_for_each_safe(l, n, &device->ccw_queue) {
1268                 cqr = list_entry(l, struct dasd_ccw_req, list);
1269                 /* Flush all request or only block device requests? */
1270                 if (all == 0 && cqr->callback == dasd_end_request_cb)
1271                         continue;
1272                 if (cqr->status == DASD_CQR_IN_IO)
1273                         device->discipline->term_IO(cqr);
1274                 if (cqr->status != DASD_CQR_DONE ||
1275                     cqr->status != DASD_CQR_FAILED) {
1276                         cqr->status = DASD_CQR_FAILED;
1277                         cqr->stopclk = get_clock();
1278                 }
1279                 /* Process finished ERP request. */
1280                 if (cqr->refers) {
1281                         __dasd_process_erp(device, cqr);
1282                         continue;
1283                 }
1284                 /* Rechain request on device request queue */
1285                 cqr->endclk = get_clock();
1286                 list_move_tail(&cqr->list, &flush_queue);
1287         }
1288         spin_unlock_irq(get_ccwdev_lock(device->cdev));
1289         /* Now call the callback function of flushed requests */
1290         list_for_each_safe(l, n, &flush_queue) {
1291                 cqr = list_entry(l, struct dasd_ccw_req, list);
1292                 if (cqr->callback != NULL)
1293                         (cqr->callback)(cqr, cqr->callback_data);
1294         }
1295 }
1296
1297 /*
1298  * Acquire the device lock and process queues for the device.
1299  */
1300 static void
1301 dasd_tasklet(struct dasd_device * device)
1302 {
1303         struct list_head final_queue;
1304         struct list_head *l, *n;
1305         struct dasd_ccw_req *cqr;
1306
1307         atomic_set (&device->tasklet_scheduled, 0);
1308         INIT_LIST_HEAD(&final_queue);
1309         spin_lock_irq(get_ccwdev_lock(device->cdev));
1310         /* Check expire time of first request on the ccw queue. */
1311         __dasd_check_expire(device);
1312         /* Finish off requests on ccw queue */
1313         __dasd_process_ccw_queue(device, &final_queue);
1314         spin_unlock_irq(get_ccwdev_lock(device->cdev));
1315         /* Now call the callback function of requests with final status */
1316         list_for_each_safe(l, n, &final_queue) {
1317                 cqr = list_entry(l, struct dasd_ccw_req, list);
1318                 list_del(&cqr->list);
1319                 if (cqr->callback != NULL)
1320                         (cqr->callback)(cqr, cqr->callback_data);
1321         }
1322         spin_lock_irq(&device->request_queue_lock);
1323         spin_lock(get_ccwdev_lock(device->cdev));
1324         /* Get new request from the block device request queue */
1325         __dasd_process_blk_queue(device);
1326         /* Now check if the head of the ccw queue needs to be started. */
1327         __dasd_start_head(device);
1328         spin_unlock(get_ccwdev_lock(device->cdev));
1329         spin_unlock_irq(&device->request_queue_lock);
1330         dasd_put_device(device);
1331 }
1332
1333 /*
1334  * Schedules a call to dasd_tasklet over the device tasklet.
1335  */
1336 void
1337 dasd_schedule_bh(struct dasd_device * device)
1338 {
1339         /* Protect against rescheduling. */
1340         if (atomic_compare_and_swap (0, 1, &device->tasklet_scheduled))
1341                 return;
1342         dasd_get_device(device);
1343         tasklet_hi_schedule(&device->tasklet);
1344 }
1345
1346 /*
1347  * Queue a request to the head of the ccw_queue. Start the I/O if
1348  * possible.
1349  */
1350 void
1351 dasd_add_request_head(struct dasd_ccw_req *req)
1352 {
1353         struct dasd_device *device;
1354         unsigned long flags;
1355
1356         device = req->device;
1357         spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
1358         req->status = DASD_CQR_QUEUED;
1359         req->device = device;
1360         list_add(&req->list, &device->ccw_queue);
1361         /* let the bh start the request to keep them in order */
1362         dasd_schedule_bh(device);
1363         spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
1364 }
1365
1366 /*
1367  * Queue a request to the tail of the ccw_queue. Start the I/O if
1368  * possible.
1369  */
1370 void
1371 dasd_add_request_tail(struct dasd_ccw_req *req)
1372 {
1373         struct dasd_device *device;
1374         unsigned long flags;
1375
1376         device = req->device;
1377         spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
1378         req->status = DASD_CQR_QUEUED;
1379         req->device = device;
1380         list_add_tail(&req->list, &device->ccw_queue);
1381         /* let the bh start the request to keep them in order */
1382         dasd_schedule_bh(device);
1383         spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
1384 }
1385
1386 /*
1387  * Wakeup callback.
1388  */
1389 static void
1390 dasd_wakeup_cb(struct dasd_ccw_req *cqr, void *data)
1391 {
1392         wake_up((wait_queue_head_t *) data);
1393 }
1394
1395 static inline int
1396 _wait_for_wakeup(struct dasd_ccw_req *cqr)
1397 {
1398         struct dasd_device *device;
1399         int rc;
1400
1401         device = cqr->device;
1402         spin_lock_irq(get_ccwdev_lock(device->cdev));
1403         rc = cqr->status == DASD_CQR_DONE || cqr->status == DASD_CQR_FAILED;
1404         spin_unlock_irq(get_ccwdev_lock(device->cdev));
1405         return rc;
1406 }
1407
1408 /*
1409  * Attempts to start a special ccw queue and waits for its completion.
1410  */
1411 int
1412 dasd_sleep_on(struct dasd_ccw_req * cqr)
1413 {
1414         wait_queue_head_t wait_q;
1415         struct dasd_device *device;
1416         int rc;
1417         
1418         device = cqr->device;
1419         spin_lock_irq(get_ccwdev_lock(device->cdev));
1420         
1421         init_waitqueue_head (&wait_q);
1422         cqr->callback = dasd_wakeup_cb;
1423         cqr->callback_data = (void *) &wait_q;
1424         cqr->status = DASD_CQR_QUEUED;
1425         list_add_tail(&cqr->list, &device->ccw_queue);
1426         
1427         /* let the bh start the request to keep them in order */
1428         dasd_schedule_bh(device);
1429         
1430         spin_unlock_irq(get_ccwdev_lock(device->cdev));
1431
1432         wait_event(wait_q, _wait_for_wakeup(cqr));
1433         
1434         /* Request status is either done or failed. */
1435         rc = (cqr->status == DASD_CQR_FAILED) ? -EIO : 0;
1436         return rc;
1437 }
1438
1439 /*
1440  * Attempts to start a special ccw queue and wait interruptible
1441  * for its completion.
1442  */
1443 int
1444 dasd_sleep_on_interruptible(struct dasd_ccw_req * cqr)
1445 {
1446         wait_queue_head_t wait_q;
1447         struct dasd_device *device;
1448         int rc, finished;
1449
1450         device = cqr->device;
1451         spin_lock_irq(get_ccwdev_lock(device->cdev));
1452
1453         init_waitqueue_head (&wait_q);
1454         cqr->callback = dasd_wakeup_cb;
1455         cqr->callback_data = (void *) &wait_q;
1456         cqr->status = DASD_CQR_QUEUED;
1457         list_add_tail(&cqr->list, &device->ccw_queue);
1458
1459         /* let the bh start the request to keep them in order */
1460         dasd_schedule_bh(device);
1461         spin_unlock_irq(get_ccwdev_lock(device->cdev));
1462
1463         finished = 0;
1464         while (!finished) {
1465                 rc = wait_event_interruptible(wait_q, _wait_for_wakeup(cqr));
1466                 if (rc != -ERESTARTSYS) {
1467                         /* Request status is either done or failed. */
1468                         rc = (cqr->status == DASD_CQR_FAILED) ? -EIO : 0;
1469                         break;
1470                 }
1471                 spin_lock_irq(get_ccwdev_lock(device->cdev));
1472                 if (cqr->status == DASD_CQR_IN_IO &&
1473                     device->discipline->term_IO(cqr) == 0) {
1474                         list_del(&cqr->list);
1475                         finished = 1;
1476                 }
1477                 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1478         }
1479         return rc;
1480 }
1481
1482 /*
1483  * Whoa nelly now it gets really hairy. For some functions (e.g. steal lock
1484  * for eckd devices) the currently running request has to be terminated
1485  * and be put back to status queued, before the special request is added
1486  * to the head of the queue. Then the special request is waited on normally.
1487  */
1488 static inline int
1489 _dasd_term_running_cqr(struct dasd_device *device)
1490 {
1491         struct dasd_ccw_req *cqr;
1492         int rc;
1493
1494         if (list_empty(&device->ccw_queue))
1495                 return 0;
1496         cqr = list_entry(device->ccw_queue.next, struct dasd_ccw_req, list);
1497         rc = device->discipline->term_IO(cqr);
1498         if (rc == 0) {
1499                 /* termination successful */
1500                 cqr->status = DASD_CQR_QUEUED;
1501                 cqr->startclk = cqr->stopclk = 0;
1502                 cqr->starttime = 0;
1503         }
1504         return rc;
1505 }
1506
1507 int
1508 dasd_sleep_on_immediatly(struct dasd_ccw_req * cqr)
1509 {
1510         wait_queue_head_t wait_q;
1511         struct dasd_device *device;
1512         int rc;
1513         
1514         device = cqr->device;
1515         spin_lock_irq(get_ccwdev_lock(device->cdev));
1516         rc = _dasd_term_running_cqr(device);
1517         if (rc) {
1518                 spin_unlock_irq(get_ccwdev_lock(device->cdev));
1519                 return rc;
1520         }
1521         
1522         init_waitqueue_head (&wait_q);
1523         cqr->callback = dasd_wakeup_cb;
1524         cqr->callback_data = (void *) &wait_q;
1525         cqr->status = DASD_CQR_QUEUED;
1526         list_add(&cqr->list, &device->ccw_queue);
1527         
1528         /* let the bh start the request to keep them in order */
1529         dasd_schedule_bh(device);
1530         
1531         spin_unlock_irq(get_ccwdev_lock(device->cdev));
1532
1533         wait_event(wait_q, _wait_for_wakeup(cqr));
1534         
1535         /* Request status is either done or failed. */
1536         rc = (cqr->status == DASD_CQR_FAILED) ? -EIO : 0;
1537         return rc;
1538 }
1539
1540 /*
1541  * Cancels a request that was started with dasd_sleep_on_req.
1542  * This is useful to timeout requests. The request will be
1543  * terminated if it is currently in i/o.
1544  * Returns 1 if the request has been terminated.
1545  */
1546 int
1547 dasd_cancel_req(struct dasd_ccw_req *cqr)
1548 {
1549         struct dasd_device *device = cqr->device;
1550         unsigned long flags;
1551         int rc;
1552
1553         rc = 0;
1554         spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
1555         switch (cqr->status) {
1556         case DASD_CQR_QUEUED:
1557                 /* request was not started - just set to failed */
1558                 cqr->status = DASD_CQR_FAILED;
1559                 break;
1560         case DASD_CQR_IN_IO:
1561                 /* request in IO - terminate IO and release again */
1562                 if (device->discipline->term_IO(cqr) != 0)
1563                         /* what to do if unable to terminate ??????
1564                            e.g. not _IN_IO */
1565                         cqr->status = DASD_CQR_FAILED;
1566                 cqr->stopclk = get_clock();
1567                 rc = 1;
1568                 break;
1569         case DASD_CQR_DONE:
1570         case DASD_CQR_FAILED:
1571                 /* already finished - do nothing */
1572                 break;
1573         default:
1574                 DEV_MESSAGE(KERN_ALERT, device,
1575                             "invalid status %02x in request",
1576                             cqr->status);
1577                 BUG();
1578
1579         }
1580         spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
1581         dasd_schedule_bh(device);
1582         return rc;
1583 }
1584
1585 /*
1586  * SECTION: Block device operations (request queue, partitions, open, release).
1587  */
1588
1589 /*
1590  * Dasd request queue function. Called from ll_rw_blk.c
1591  */
1592 static void
1593 do_dasd_request(request_queue_t * queue)
1594 {
1595         struct dasd_device *device;
1596
1597         device = (struct dasd_device *) queue->queuedata;
1598         spin_lock(get_ccwdev_lock(device->cdev));
1599         /* Get new request from the block device request queue */
1600         __dasd_process_blk_queue(device);
1601         /* Now check if the head of the ccw queue needs to be started. */
1602         __dasd_start_head(device);
1603         spin_unlock(get_ccwdev_lock(device->cdev));
1604 }
1605
1606 /*
1607  * Allocate and initialize request queue.
1608  */
1609 static int
1610 dasd_alloc_queue(struct dasd_device * device)
1611 {
1612         device->request_queue = blk_init_queue(do_dasd_request,
1613                                                &device->request_queue_lock);
1614         if (device->request_queue == NULL)
1615                 return -ENOMEM;
1616
1617         device->request_queue->queuedata = device;
1618 #if 0
1619         elevator_exit(device->request_queue);
1620         rc = elevator_init(device->request_queue, &elevator_noop);
1621         if (rc) {
1622                 blk_cleanup_queue(device->request_queue);
1623                 return rc;
1624         }
1625 #endif
1626         return 0;
1627 }
1628
1629 /*
1630  * Allocate and initialize request queue.
1631  */
1632 static void
1633 dasd_setup_queue(struct dasd_device * device)
1634 {
1635         int max;
1636
1637         blk_queue_hardsect_size(device->request_queue, device->bp_block);
1638         max = device->discipline->max_blocks << device->s2b_shift;
1639         blk_queue_max_sectors(device->request_queue, max);
1640         blk_queue_max_phys_segments(device->request_queue, -1L);
1641         blk_queue_max_hw_segments(device->request_queue, -1L);
1642         blk_queue_max_segment_size(device->request_queue, -1L);
1643         blk_queue_segment_boundary(device->request_queue, -1L);
1644 }
1645
1646 /*
1647  * Deactivate and free request queue.
1648  */
1649 static void
1650 dasd_free_queue(struct dasd_device * device)
1651 {
1652         if (device->request_queue) {
1653                 blk_cleanup_queue(device->request_queue);
1654                 device->request_queue = NULL;
1655         }
1656 }
1657
1658 /*
1659  * Flush request on the request queue.
1660  */
1661 static void
1662 dasd_flush_request_queue(struct dasd_device * device)
1663 {
1664         struct request *req;
1665
1666         if (!device->request_queue)
1667                 return;
1668         
1669         spin_lock_irq(&device->request_queue_lock);
1670         while (!list_empty(&device->request_queue->queue_head)) {
1671                 req = elv_next_request(device->request_queue);
1672                 if (req == NULL)
1673                         break;
1674                 dasd_end_request(req, 0);
1675                 blkdev_dequeue_request(req);
1676         }
1677         spin_unlock_irq(&device->request_queue_lock);
1678 }
1679
1680 static int
1681 dasd_open(struct inode *inp, struct file *filp)
1682 {
1683         struct gendisk *disk = inp->i_bdev->bd_disk;
1684         struct dasd_device *device = disk->private_data;
1685         int rc;
1686
1687         atomic_inc(&device->open_count);
1688         if (test_bit(DASD_FLAG_OFFLINE, &device->flags)) {
1689                 rc = -ENODEV;
1690                 goto unlock;
1691         }
1692
1693         if (!try_module_get(device->discipline->owner)) {
1694                 rc = -EINVAL;
1695                 goto unlock;
1696         }
1697
1698         if (dasd_probeonly) {
1699                 MESSAGE(KERN_INFO,
1700                         "No access to device %s due to probeonly mode",
1701                         disk->disk_name);
1702                 rc = -EPERM;
1703                 goto out;
1704         }
1705
1706         if (device->state < DASD_STATE_BASIC) {
1707                 DBF_DEV_EVENT(DBF_ERR, device, " %s",
1708                               " Cannot open unrecognized device");
1709                 rc = -ENODEV;
1710                 goto out;
1711         }
1712
1713         return 0;
1714
1715 out:
1716         module_put(device->discipline->owner);
1717 unlock:
1718         atomic_dec(&device->open_count);
1719         return rc;
1720 }
1721
1722 static int
1723 dasd_release(struct inode *inp, struct file *filp)
1724 {
1725         struct gendisk *disk = inp->i_bdev->bd_disk;
1726         struct dasd_device *device = disk->private_data;
1727
1728         atomic_dec(&device->open_count);
1729         module_put(device->discipline->owner);
1730         return 0;
1731 }
1732
1733 struct block_device_operations
1734 dasd_device_operations = {
1735         .owner          = THIS_MODULE,
1736         .open           = dasd_open,
1737         .release        = dasd_release,
1738         .ioctl          = dasd_ioctl,
1739 };
1740
1741
1742 static void
1743 dasd_exit(void)
1744 {
1745 #ifdef CONFIG_PROC_FS
1746         dasd_proc_exit();
1747 #endif
1748         dasd_ioctl_exit();
1749         dasd_gendisk_exit();
1750         dasd_devmap_exit();
1751         devfs_remove("dasd");
1752         if (dasd_debug_area != NULL) {
1753                 debug_unregister(dasd_debug_area);
1754                 dasd_debug_area = NULL;
1755         }
1756 }
1757
1758 /*
1759  * SECTION: common functions for ccw_driver use
1760  */
1761
1762 /* initial attempt at a probe function. this can be simplified once
1763  * the other detection code is gone */
1764 int
1765 dasd_generic_probe (struct ccw_device *cdev,
1766                     struct dasd_discipline *discipline)
1767 {
1768         int ret;
1769
1770         ret = dasd_add_sysfs_files(cdev);
1771         if (ret) {
1772                 printk(KERN_WARNING
1773                        "dasd_generic_probe: could not add sysfs entries "
1774                        "for %s\n", cdev->dev.bus_id);
1775         }
1776
1777         cdev->handler = &dasd_int_handler;
1778
1779         return ret;
1780 }
1781
1782 /* this will one day be called from a global not_oper handler.
1783  * It is also used by driver_unregister during module unload */
1784 void
1785 dasd_generic_remove (struct ccw_device *cdev)
1786 {
1787         struct dasd_device *device;
1788
1789         dasd_remove_sysfs_files(cdev);
1790         device = dasd_device_from_cdev(cdev);
1791         if (IS_ERR(device))
1792                 return;
1793         if (test_and_set_bit(DASD_FLAG_OFFLINE, &device->flags)) {
1794                 /* Already doing offline processing */
1795                 dasd_put_device(device);
1796                 return;
1797         }
1798         /*
1799          * This device is removed unconditionally. Set offline
1800          * flag to prevent dasd_open from opening it while it is
1801          * no quite down yet.
1802          */
1803         dasd_set_target_state(device, DASD_STATE_NEW);
1804         /* dasd_delete_device destroys the device reference. */
1805         dasd_delete_device(device);
1806 }
1807
1808 /* activate a device. This is called from dasd_{eckd,fba}_probe() when either
1809  * the device is detected for the first time and is supposed to be used
1810  * or the user has started activation through sysfs */
1811 int
1812 dasd_generic_set_online (struct ccw_device *cdev,
1813                          struct dasd_discipline *discipline)
1814
1815 {
1816         struct dasd_device *device;
1817         int rc;
1818
1819         device = dasd_create_device(cdev);
1820         if (IS_ERR(device))
1821                 return PTR_ERR(device);
1822
1823         if (test_bit(DASD_FLAG_USE_DIAG, &device->flags)) {
1824                 if (!dasd_diag_discipline_pointer) {
1825                         printk (KERN_WARNING
1826                                 "dasd_generic couldn't online device %s "
1827                                 "- discipline DIAG not available\n",
1828                                 cdev->dev.bus_id);
1829                         dasd_delete_device(device);
1830                         return -ENODEV;
1831                 }
1832                 discipline = dasd_diag_discipline_pointer;
1833         }
1834         device->discipline = discipline;
1835
1836         rc = discipline->check_device(device);
1837         if (rc) {
1838                 printk (KERN_WARNING
1839                         "dasd_generic couldn't online device %s "
1840                         "with discipline %s\n", 
1841                         cdev->dev.bus_id, discipline->name);
1842                 dasd_delete_device(device);
1843                 return rc;
1844         }
1845
1846         dasd_set_target_state(device, DASD_STATE_ONLINE);
1847         if (device->state <= DASD_STATE_KNOWN) {
1848                 printk (KERN_WARNING
1849                         "dasd_generic discipline not found for %s\n",
1850                         cdev->dev.bus_id);
1851                 rc = -ENODEV;
1852                 dasd_set_target_state(device, DASD_STATE_NEW);
1853                 dasd_delete_device(device);
1854         } else
1855                 pr_debug("dasd_generic device %s found\n",
1856                                 cdev->dev.bus_id);
1857
1858         /* FIXME: we have to wait for the root device but we don't want
1859          * to wait for each single device but for all at once. */
1860         wait_event(dasd_init_waitq, _wait_for_device(device));
1861
1862         dasd_put_device(device);
1863
1864         return rc;
1865 }
1866
1867 int
1868 dasd_generic_set_offline (struct ccw_device *cdev)
1869 {
1870         struct dasd_device *device;
1871         int max_count;
1872
1873         device = dasd_device_from_cdev(cdev);
1874         if (IS_ERR(device))
1875                 return PTR_ERR(device);
1876         if (test_and_set_bit(DASD_FLAG_OFFLINE, &device->flags)) {
1877                 /* Already doing offline processing */
1878                 dasd_put_device(device);
1879                 return 0;
1880         }
1881         /*
1882          * We must make sure that this device is currently not in use.
1883          * The open_count is increased for every opener, that includes
1884          * the blkdev_get in dasd_scan_partitions. We are only interested
1885          * in the other openers.
1886          */
1887         max_count = device->bdev ? 0 : -1;
1888         if (atomic_read(&device->open_count) > max_count) {
1889                 printk (KERN_WARNING "Can't offline dasd device with open"
1890                         " count = %i.\n",
1891                         atomic_read(&device->open_count));
1892                 clear_bit(DASD_FLAG_OFFLINE, &device->flags);
1893                 dasd_put_device(device);
1894                 return -EBUSY;
1895         }
1896         dasd_set_target_state(device, DASD_STATE_NEW);
1897         /* dasd_delete_device destroys the device reference. */
1898         dasd_delete_device(device);
1899
1900         return 0;
1901 }
1902
1903 int
1904 dasd_generic_notify(struct ccw_device *cdev, int event)
1905 {
1906         struct dasd_device *device;
1907         struct dasd_ccw_req *cqr;
1908         unsigned long flags;
1909         int ret;
1910
1911         device = dasd_device_from_cdev(cdev);
1912         if (IS_ERR(device))
1913                 return 0;
1914         spin_lock_irqsave(get_ccwdev_lock(cdev), flags);
1915         ret = 0;
1916         switch (event) {
1917         case CIO_GONE:
1918         case CIO_NO_PATH:
1919                 if (device->state < DASD_STATE_BASIC)
1920                         break;
1921                 /* Device is active. We want to keep it. */
1922                 if (test_bit(DASD_FLAG_DSC_ERROR, &device->flags)) {
1923                         list_for_each_entry(cqr, &device->ccw_queue, list)
1924                                 if (cqr->status == DASD_CQR_IN_IO)
1925                                         cqr->status = DASD_CQR_FAILED;
1926                         device->stopped |= DASD_STOPPED_DC_EIO;
1927                         dasd_schedule_bh(device);
1928                 } else {
1929                         list_for_each_entry(cqr, &device->ccw_queue, list)
1930                                 if (cqr->status == DASD_CQR_IN_IO)
1931                                         cqr->status = DASD_CQR_QUEUED;
1932                         device->stopped |= DASD_STOPPED_DC_WAIT;
1933                         dasd_set_timer(device, 0);
1934                 }
1935                 ret = 1;
1936                 break;
1937         case CIO_OPER:
1938                 /* FIXME: add a sanity check. */
1939                 device->stopped &= ~(DASD_STOPPED_DC_WAIT|DASD_STOPPED_DC_EIO);
1940                 dasd_schedule_bh(device);
1941                 ret = 1;
1942                 break;
1943         }
1944         spin_unlock_irqrestore(get_ccwdev_lock(cdev), flags);
1945         dasd_put_device(device);
1946         return ret;
1947 }
1948
1949 /*
1950  * Automatically online either all dasd devices (dasd_autodetect) or
1951  * all devices specified with dasd= parameters.
1952  */
1953 void
1954 dasd_generic_auto_online (struct ccw_driver *dasd_discipline_driver)
1955 {
1956         struct device_driver *drv;
1957         struct device *d, *dev;
1958         struct ccw_device *cdev;
1959
1960         drv = get_driver(&dasd_discipline_driver->driver);
1961         down_read(&drv->bus->subsys.rwsem);
1962         dev = NULL;
1963         list_for_each_entry(d, &drv->devices, driver_list) {
1964                 dev = get_device(d);
1965                 if (!dev)
1966                         continue;
1967                 cdev = to_ccwdev(dev);
1968                 if (dasd_autodetect || dasd_busid_known(cdev->dev.bus_id) == 0)
1969                         ccw_device_set_online(cdev);
1970                 put_device(dev);
1971         }
1972         up_read(&drv->bus->subsys.rwsem);
1973         put_driver(drv);
1974 }
1975
1976 static int __init
1977 dasd_init(void)
1978 {
1979         int rc;
1980
1981         init_waitqueue_head(&dasd_init_waitq);
1982
1983         /* register 'common' DASD debug area, used faor all DBF_XXX calls */
1984         dasd_debug_area = debug_register("dasd", 0, 2, 8 * sizeof (long));
1985         if (dasd_debug_area == NULL) {
1986                 rc = -ENOMEM;
1987                 goto failed;
1988         }
1989         debug_register_view(dasd_debug_area, &debug_hex_ascii_view);
1990         debug_set_level(dasd_debug_area, DBF_ERR);
1991
1992         DBF_EVENT(DBF_EMERG, "%s", "debug area created");
1993
1994         dasd_diag_discipline_pointer = NULL;
1995
1996         rc = devfs_mk_dir("dasd");
1997         if (rc)
1998                 goto failed;
1999         rc = dasd_devmap_init();
2000         if (rc)
2001                 goto failed;
2002         rc = dasd_gendisk_init();
2003         if (rc)
2004                 goto failed;
2005         rc = dasd_parse();
2006         if (rc)
2007                 goto failed;
2008         rc = dasd_ioctl_init();
2009         if (rc)
2010                 goto failed;
2011 #ifdef CONFIG_PROC_FS
2012         rc = dasd_proc_init();
2013         if (rc)
2014                 goto failed;
2015 #endif
2016
2017         return 0;
2018 failed:
2019         MESSAGE(KERN_INFO, "%s", "initialization not performed due to errors");
2020         dasd_exit();
2021         return rc;
2022 }
2023
2024 module_init(dasd_init);
2025 module_exit(dasd_exit);
2026
2027 EXPORT_SYMBOL(dasd_debug_area);
2028 EXPORT_SYMBOL(dasd_diag_discipline_pointer);
2029
2030 EXPORT_SYMBOL(dasd_add_request_head);
2031 EXPORT_SYMBOL(dasd_add_request_tail);
2032 EXPORT_SYMBOL(dasd_cancel_req);
2033 EXPORT_SYMBOL(dasd_clear_timer);
2034 EXPORT_SYMBOL(dasd_enable_device);
2035 EXPORT_SYMBOL(dasd_int_handler);
2036 EXPORT_SYMBOL(dasd_kfree_request);
2037 EXPORT_SYMBOL(dasd_kick_device);
2038 EXPORT_SYMBOL(dasd_kmalloc_request);
2039 EXPORT_SYMBOL(dasd_schedule_bh);
2040 EXPORT_SYMBOL(dasd_set_target_state);
2041 EXPORT_SYMBOL(dasd_set_timer);
2042 EXPORT_SYMBOL(dasd_sfree_request);
2043 EXPORT_SYMBOL(dasd_sleep_on);
2044 EXPORT_SYMBOL(dasd_sleep_on_immediatly);
2045 EXPORT_SYMBOL(dasd_sleep_on_interruptible);
2046 EXPORT_SYMBOL(dasd_smalloc_request);
2047 EXPORT_SYMBOL(dasd_start_IO);
2048 EXPORT_SYMBOL(dasd_term_IO);
2049
2050 EXPORT_SYMBOL_GPL(dasd_generic_probe);
2051 EXPORT_SYMBOL_GPL(dasd_generic_remove);
2052 EXPORT_SYMBOL_GPL(dasd_generic_notify);
2053 EXPORT_SYMBOL_GPL(dasd_generic_set_online);
2054 EXPORT_SYMBOL_GPL(dasd_generic_set_offline);
2055 EXPORT_SYMBOL_GPL(dasd_generic_auto_online);
2056
2057 /*
2058  * Overrides for Emacs so that we follow Linus's tabbing style.
2059  * Emacs will notice this stuff at the end of the file and automatically
2060  * adjust the settings for this buffer only.  This must remain at the end
2061  * of the file.
2062  * ---------------------------------------------------------------------------
2063  * Local variables:
2064  * c-indent-level: 4
2065  * c-brace-imaginary-offset: 0
2066  * c-brace-offset: -4
2067  * c-argdecl-indent: 4
2068  * c-label-offset: -4
2069  * c-continued-statement-offset: 4
2070  * c-continued-brace-offset: 0
2071  * indent-tabs-mode: 1
2072  * tab-width: 8
2073  * End:
2074  */