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