2 * File...........: linux/drivers/s390/block/dasd_eckd.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,2000
12 #include <linux/stddef.h>
13 #include <linux/kernel.h>
14 #include <linux/slab.h>
15 #include <linux/hdreg.h> /* HDIO_GETGEO */
16 #include <linux/bio.h>
17 #include <linux/module.h>
18 #include <linux/init.h>
20 #include <asm/debug.h>
21 #include <asm/idals.h>
22 #include <asm/ebcdic.h>
24 #include <asm/todclk.h>
25 #include <asm/uaccess.h>
27 #include <asm/ccwdev.h>
30 #include "dasd_eckd.h"
34 #endif /* PRINTK_HEADER */
35 #define PRINTK_HEADER "dasd(eckd):"
37 #define ECKD_C0(i) (i->home_bytes)
38 #define ECKD_F(i) (i->formula)
39 #define ECKD_F1(i) (ECKD_F(i)==0x01?(i->factors.f_0x01.f1):\
40 (i->factors.f_0x02.f1))
41 #define ECKD_F2(i) (ECKD_F(i)==0x01?(i->factors.f_0x01.f2):\
42 (i->factors.f_0x02.f2))
43 #define ECKD_F3(i) (ECKD_F(i)==0x01?(i->factors.f_0x01.f3):\
44 (i->factors.f_0x02.f3))
45 #define ECKD_F4(i) (ECKD_F(i)==0x02?(i->factors.f_0x02.f4):0)
46 #define ECKD_F5(i) (ECKD_F(i)==0x02?(i->factors.f_0x02.f5):0)
47 #define ECKD_F6(i) (i->factor6)
48 #define ECKD_F7(i) (i->factor7)
49 #define ECKD_F8(i) (i->factor8)
51 MODULE_LICENSE("GPL");
53 static struct dasd_discipline dasd_eckd_discipline;
55 /* The ccw bus type uses this table to find devices that it sends to
57 static struct ccw_device_id dasd_eckd_ids[] = {
58 { CCW_DEVICE_DEVTYPE (0x3990, 0, 0x3390, 0), .driver_info = 0x1},
59 { CCW_DEVICE_DEVTYPE (0x2105, 0, 0x3390, 0), .driver_info = 0x2},
60 { CCW_DEVICE_DEVTYPE (0x3880, 0, 0x3390, 0), .driver_info = 0x3},
61 { CCW_DEVICE_DEVTYPE (0x3990, 0, 0x3380, 0), .driver_info = 0x4},
62 { CCW_DEVICE_DEVTYPE (0x2105, 0, 0x3380, 0), .driver_info = 0x5},
63 { CCW_DEVICE_DEVTYPE (0x9343, 0, 0x9345, 0), .driver_info = 0x6},
64 { CCW_DEVICE_DEVTYPE (0x2107, 0, 0x3390, 0), .driver_info = 0x7},
65 { CCW_DEVICE_DEVTYPE (0x2107, 0, 0x3380, 0), .driver_info = 0x8},
66 { CCW_DEVICE_DEVTYPE (0x1750, 0, 0x3390, 0), .driver_info = 0x9},
67 { CCW_DEVICE_DEVTYPE (0x1750, 0, 0x3380, 0), .driver_info = 0xa},
68 { /* end of list */ },
71 MODULE_DEVICE_TABLE(ccw, dasd_eckd_ids);
73 static struct ccw_driver dasd_eckd_driver; /* see below */
75 /* initial attempt at a probe function. this can be simplified once
76 * the other detection code is gone */
78 dasd_eckd_probe (struct ccw_device *cdev)
82 /* set ECKD specific ccw-device options */
83 ret = ccw_device_set_options(cdev, CCWDEV_ALLOW_FORCE);
86 "dasd_eckd_probe: could not set ccw-device options "
87 "for %s\n", cdev->dev.bus_id);
90 ret = dasd_generic_probe(cdev, &dasd_eckd_discipline);
95 dasd_eckd_set_online(struct ccw_device *cdev)
97 return dasd_generic_set_online(cdev, &dasd_eckd_discipline);
100 static struct ccw_driver dasd_eckd_driver = {
102 .owner = THIS_MODULE,
103 .ids = dasd_eckd_ids,
104 .probe = dasd_eckd_probe,
105 .remove = dasd_generic_remove,
106 .set_offline = dasd_generic_set_offline,
107 .set_online = dasd_eckd_set_online,
108 .notify = dasd_generic_notify,
111 static const int sizes_trk0[] = { 28, 148, 84 };
112 #define LABEL_SIZE 140
114 static inline unsigned int
115 round_up_multiple(unsigned int no, unsigned int mult)
118 return (rem ? no - rem + mult : no);
121 static inline unsigned int
122 ceil_quot(unsigned int d1, unsigned int d2)
124 return (d1 + (d2 - 1)) / d2;
128 recs_per_track(struct dasd_eckd_characteristics * rdc,
129 unsigned int kl, unsigned int dl)
133 switch (rdc->dev_type) {
136 return 1499 / (15 + 7 + ceil_quot(kl + 12, 32) +
137 ceil_quot(dl + 12, 32));
139 return 1499 / (15 + ceil_quot(dl + 12, 32));
141 dn = ceil_quot(dl + 6, 232) + 1;
143 kn = ceil_quot(kl + 6, 232) + 1;
144 return 1729 / (10 + 9 + ceil_quot(kl + 6 * kn, 34) +
145 9 + ceil_quot(dl + 6 * dn, 34));
147 return 1729 / (10 + 9 + ceil_quot(dl + 6 * dn, 34));
149 dn = ceil_quot(dl + 6, 232) + 1;
151 kn = ceil_quot(kl + 6, 232) + 1;
152 return 1420 / (18 + 7 + ceil_quot(kl + 6 * kn, 34) +
153 ceil_quot(dl + 6 * dn, 34));
155 return 1420 / (18 + 7 + ceil_quot(dl + 6 * dn, 34));
161 check_XRC (struct ccw1 *de_ccw,
162 struct DE_eckd_data *data,
163 struct dasd_device *device)
165 struct dasd_eckd_private *private;
168 private = (struct dasd_eckd_private *) device->private;
169 if (!private->rdc_data.facilities.XRC_supported)
172 /* switch on System Time Stamp - needed for XRC Support */
173 data->ga_extended |= 0x08; /* switch on 'Time Stamp Valid' */
174 data->ga_extended |= 0x02; /* switch on 'Extended Parameter' */
176 rc = get_sync_clock(&data->ep_sys_time);
177 /* Ignore return code if sync clock is switched off. */
178 if (rc == -ENOSYS || rc == -EACCES)
181 de_ccw->count = sizeof(struct DE_eckd_data);
182 de_ccw->flags |= CCW_FLAG_SLI;
187 define_extent(struct ccw1 * ccw, struct DE_eckd_data * data, int trk,
188 int totrk, int cmd, struct dasd_device * device)
190 struct dasd_eckd_private *private;
191 struct ch_t geo, beg, end;
194 private = (struct dasd_eckd_private *) device->private;
196 ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
199 ccw->cda = (__u32) __pa(data);
201 memset(data, 0, sizeof(struct DE_eckd_data));
203 case DASD_ECKD_CCW_READ_HOME_ADDRESS:
204 case DASD_ECKD_CCW_READ_RECORD_ZERO:
205 case DASD_ECKD_CCW_READ:
206 case DASD_ECKD_CCW_READ_MT:
207 case DASD_ECKD_CCW_READ_CKD:
208 case DASD_ECKD_CCW_READ_CKD_MT:
209 case DASD_ECKD_CCW_READ_KD:
210 case DASD_ECKD_CCW_READ_KD_MT:
211 case DASD_ECKD_CCW_READ_COUNT:
212 data->mask.perm = 0x1;
213 data->attributes.operation = private->attrib.operation;
215 case DASD_ECKD_CCW_WRITE:
216 case DASD_ECKD_CCW_WRITE_MT:
217 case DASD_ECKD_CCW_WRITE_KD:
218 case DASD_ECKD_CCW_WRITE_KD_MT:
219 data->mask.perm = 0x02;
220 data->attributes.operation = private->attrib.operation;
221 rc = check_XRC (ccw, data, device);
223 case DASD_ECKD_CCW_WRITE_CKD:
224 case DASD_ECKD_CCW_WRITE_CKD_MT:
225 data->attributes.operation = DASD_BYPASS_CACHE;
226 rc = check_XRC (ccw, data, device);
228 case DASD_ECKD_CCW_ERASE:
229 case DASD_ECKD_CCW_WRITE_HOME_ADDRESS:
230 case DASD_ECKD_CCW_WRITE_RECORD_ZERO:
231 data->mask.perm = 0x3;
232 data->mask.auth = 0x1;
233 data->attributes.operation = DASD_BYPASS_CACHE;
234 rc = check_XRC (ccw, data, device);
237 DEV_MESSAGE(KERN_ERR, device, "unknown opcode 0x%x", cmd);
241 data->attributes.mode = 0x3; /* ECKD */
243 if ((private->rdc_data.cu_type == 0x2105 ||
244 private->rdc_data.cu_type == 0x2107 ||
245 private->rdc_data.cu_type == 0x1750)
246 && !(private->uses_cdl && trk < 2))
247 data->ga_extended |= 0x40; /* Regular Data Format Mode */
249 geo.cyl = private->rdc_data.no_cyl;
250 geo.head = private->rdc_data.trk_per_cyl;
251 beg.cyl = trk / geo.head;
252 beg.head = trk % geo.head;
253 end.cyl = totrk / geo.head;
254 end.head = totrk % geo.head;
256 /* check for sequential prestage - enhance cylinder range */
257 if (data->attributes.operation == DASD_SEQ_PRESTAGE ||
258 data->attributes.operation == DASD_SEQ_ACCESS) {
260 if (end.cyl + private->attrib.nr_cyl < geo.cyl)
261 end.cyl += private->attrib.nr_cyl;
263 end.cyl = (geo.cyl - 1);
266 data->beg_ext.cyl = beg.cyl;
267 data->beg_ext.head = beg.head;
268 data->end_ext.cyl = end.cyl;
269 data->end_ext.head = end.head;
273 static int check_XRC_on_prefix(struct PFX_eckd_data *pfxdata,
274 struct dasd_device *device)
276 struct dasd_eckd_private *private;
279 private = (struct dasd_eckd_private *) device->private;
280 if (!private->rdc_data.facilities.XRC_supported)
283 /* switch on System Time Stamp - needed for XRC Support */
284 pfxdata->define_extend.ga_extended |= 0x08; /* 'Time Stamp Valid' */
285 pfxdata->define_extend.ga_extended |= 0x02; /* 'Extended Parameter' */
286 pfxdata->validity.time_stamp = 1; /* 'Time Stamp Valid' */
288 rc = get_sync_clock(&pfxdata->define_extend.ep_sys_time);
289 /* Ignore return code if sync clock is switched off. */
290 if (rc == -ENOSYS || rc == -EACCES)
295 static int prefix(struct ccw1 *ccw, struct PFX_eckd_data *pfxdata, int trk,
296 int totrk, int cmd, struct dasd_device *basedev,
297 struct dasd_device *startdev)
299 struct dasd_eckd_private *basepriv, *startpriv;
300 struct DE_eckd_data *data;
301 struct ch_t geo, beg, end;
304 basepriv = (struct dasd_eckd_private *) basedev->private;
305 startpriv = (struct dasd_eckd_private *) startdev->private;
306 data = &pfxdata->define_extend;
308 ccw->cmd_code = DASD_ECKD_CCW_PFX;
310 ccw->count = sizeof(*pfxdata);
311 ccw->cda = (__u32) __pa(pfxdata);
313 memset(pfxdata, 0, sizeof(*pfxdata));
316 pfxdata->base_address = basepriv->conf_data.ned1.unit_addr;
317 pfxdata->base_lss = basepriv->conf_data.ned1.ID;
318 pfxdata->validity.define_extend = 1;
320 /* private uid is kept up to date, conf_data may be outdated */
321 if (startpriv->uid.type != UA_BASE_DEVICE) {
322 pfxdata->validity.verify_base = 1;
323 if (startpriv->uid.type == UA_HYPER_PAV_ALIAS)
324 pfxdata->validity.hyper_pav = 1;
327 /* define extend data (mostly)*/
329 case DASD_ECKD_CCW_READ_HOME_ADDRESS:
330 case DASD_ECKD_CCW_READ_RECORD_ZERO:
331 case DASD_ECKD_CCW_READ:
332 case DASD_ECKD_CCW_READ_MT:
333 case DASD_ECKD_CCW_READ_CKD:
334 case DASD_ECKD_CCW_READ_CKD_MT:
335 case DASD_ECKD_CCW_READ_KD:
336 case DASD_ECKD_CCW_READ_KD_MT:
337 case DASD_ECKD_CCW_READ_COUNT:
338 data->mask.perm = 0x1;
339 data->attributes.operation = basepriv->attrib.operation;
341 case DASD_ECKD_CCW_WRITE:
342 case DASD_ECKD_CCW_WRITE_MT:
343 case DASD_ECKD_CCW_WRITE_KD:
344 case DASD_ECKD_CCW_WRITE_KD_MT:
345 data->mask.perm = 0x02;
346 data->attributes.operation = basepriv->attrib.operation;
347 rc = check_XRC_on_prefix(pfxdata, basedev);
349 case DASD_ECKD_CCW_WRITE_CKD:
350 case DASD_ECKD_CCW_WRITE_CKD_MT:
351 data->attributes.operation = DASD_BYPASS_CACHE;
352 rc = check_XRC_on_prefix(pfxdata, basedev);
354 case DASD_ECKD_CCW_ERASE:
355 case DASD_ECKD_CCW_WRITE_HOME_ADDRESS:
356 case DASD_ECKD_CCW_WRITE_RECORD_ZERO:
357 data->mask.perm = 0x3;
358 data->mask.auth = 0x1;
359 data->attributes.operation = DASD_BYPASS_CACHE;
360 rc = check_XRC_on_prefix(pfxdata, basedev);
363 DEV_MESSAGE(KERN_ERR, basedev, "unknown opcode 0x%x", cmd);
367 data->attributes.mode = 0x3; /* ECKD */
369 if ((basepriv->rdc_data.cu_type == 0x2105 ||
370 basepriv->rdc_data.cu_type == 0x2107 ||
371 basepriv->rdc_data.cu_type == 0x1750)
372 && !(basepriv->uses_cdl && trk < 2))
373 data->ga_extended |= 0x40; /* Regular Data Format Mode */
375 geo.cyl = basepriv->rdc_data.no_cyl;
376 geo.head = basepriv->rdc_data.trk_per_cyl;
377 beg.cyl = trk / geo.head;
378 beg.head = trk % geo.head;
379 end.cyl = totrk / geo.head;
380 end.head = totrk % geo.head;
382 /* check for sequential prestage - enhance cylinder range */
383 if (data->attributes.operation == DASD_SEQ_PRESTAGE ||
384 data->attributes.operation == DASD_SEQ_ACCESS) {
386 if (end.cyl + basepriv->attrib.nr_cyl < geo.cyl)
387 end.cyl += basepriv->attrib.nr_cyl;
389 end.cyl = (geo.cyl - 1);
392 data->beg_ext.cyl = beg.cyl;
393 data->beg_ext.head = beg.head;
394 data->end_ext.cyl = end.cyl;
395 data->end_ext.head = end.head;
400 locate_record(struct ccw1 *ccw, struct LO_eckd_data *data, int trk,
401 int rec_on_trk, int no_rec, int cmd,
402 struct dasd_device * device, int reclen)
404 struct dasd_eckd_private *private;
408 private = (struct dasd_eckd_private *) device->private;
410 DBF_DEV_EVENT(DBF_INFO, device,
411 "Locate: trk %d, rec %d, no_rec %d, cmd %d, reclen %d",
412 trk, rec_on_trk, no_rec, cmd, reclen);
414 ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
417 ccw->cda = (__u32) __pa(data);
419 memset(data, 0, sizeof(struct LO_eckd_data));
422 switch (private->rdc_data.dev_type) {
424 dn = ceil_quot(reclen + 6, 232);
425 d = 9 + ceil_quot(reclen + 6 * (dn + 1), 34);
426 sector = (49 + (rec_on_trk - 1) * (10 + d)) / 8;
429 d = 7 + ceil_quot(reclen + 12, 32);
430 sector = (39 + (rec_on_trk - 1) * (8 + d)) / 7;
434 data->sector = sector;
435 data->count = no_rec;
437 case DASD_ECKD_CCW_WRITE_HOME_ADDRESS:
438 data->operation.orientation = 0x3;
439 data->operation.operation = 0x03;
441 case DASD_ECKD_CCW_READ_HOME_ADDRESS:
442 data->operation.orientation = 0x3;
443 data->operation.operation = 0x16;
445 case DASD_ECKD_CCW_WRITE_RECORD_ZERO:
446 data->operation.orientation = 0x1;
447 data->operation.operation = 0x03;
450 case DASD_ECKD_CCW_READ_RECORD_ZERO:
451 data->operation.orientation = 0x3;
452 data->operation.operation = 0x16;
455 case DASD_ECKD_CCW_WRITE:
456 case DASD_ECKD_CCW_WRITE_MT:
457 case DASD_ECKD_CCW_WRITE_KD:
458 case DASD_ECKD_CCW_WRITE_KD_MT:
459 data->auxiliary.last_bytes_used = 0x1;
460 data->length = reclen;
461 data->operation.operation = 0x01;
463 case DASD_ECKD_CCW_WRITE_CKD:
464 case DASD_ECKD_CCW_WRITE_CKD_MT:
465 data->auxiliary.last_bytes_used = 0x1;
466 data->length = reclen;
467 data->operation.operation = 0x03;
469 case DASD_ECKD_CCW_READ:
470 case DASD_ECKD_CCW_READ_MT:
471 case DASD_ECKD_CCW_READ_KD:
472 case DASD_ECKD_CCW_READ_KD_MT:
473 data->auxiliary.last_bytes_used = 0x1;
474 data->length = reclen;
475 data->operation.operation = 0x06;
477 case DASD_ECKD_CCW_READ_CKD:
478 case DASD_ECKD_CCW_READ_CKD_MT:
479 data->auxiliary.last_bytes_used = 0x1;
480 data->length = reclen;
481 data->operation.operation = 0x16;
483 case DASD_ECKD_CCW_READ_COUNT:
484 data->operation.operation = 0x06;
486 case DASD_ECKD_CCW_ERASE:
487 data->length = reclen;
488 data->auxiliary.last_bytes_used = 0x1;
489 data->operation.operation = 0x0b;
492 DEV_MESSAGE(KERN_ERR, device, "unknown opcode 0x%x", cmd);
494 data->seek_addr.cyl = data->search_arg.cyl =
495 trk / private->rdc_data.trk_per_cyl;
496 data->seek_addr.head = data->search_arg.head =
497 trk % private->rdc_data.trk_per_cyl;
498 data->search_arg.record = rec_on_trk;
502 * Returns 1 if the block is one of the special blocks that needs
503 * to get read/written with the KD variant of the command.
504 * That is DASD_ECKD_READ_KD_MT instead of DASD_ECKD_READ_MT and
505 * DASD_ECKD_WRITE_KD_MT instead of DASD_ECKD_WRITE_MT.
506 * Luckily the KD variants differ only by one bit (0x08) from the
507 * normal variant. So don't wonder about code like:
508 * if (dasd_eckd_cdl_special(blk_per_trk, recid))
509 * ccw->cmd_code |= 0x8;
512 dasd_eckd_cdl_special(int blk_per_trk, int recid)
516 if (recid < blk_per_trk)
518 if (recid < 2 * blk_per_trk)
524 * Returns the record size for the special blocks of the cdl format.
525 * Only returns something useful if dasd_eckd_cdl_special is true
529 dasd_eckd_cdl_reclen(int recid)
532 return sizes_trk0[recid];
537 * Generate device unique id that specifies the physical device.
540 dasd_eckd_generate_uid(struct dasd_device *device, struct dasd_uid *uid)
542 struct dasd_eckd_private *private;
543 struct dasd_eckd_confdata *confdata;
545 private = (struct dasd_eckd_private *) device->private;
548 confdata = &private->conf_data;
552 memset(uid, 0, sizeof(struct dasd_uid));
553 memcpy(uid->vendor, confdata->ned1.HDA_manufacturer,
554 sizeof(uid->vendor) - 1);
555 EBCASC(uid->vendor, sizeof(uid->vendor) - 1);
556 memcpy(uid->serial, confdata->ned1.HDA_location,
557 sizeof(uid->serial) - 1);
558 EBCASC(uid->serial, sizeof(uid->serial) - 1);
559 uid->ssid = confdata->neq.subsystemID;
560 uid->real_unit_addr = confdata->ned1.unit_addr;
561 if (confdata->ned2.sneq.flags == 0x40 &&
562 confdata->ned2.sneq.format == 0x0001) {
563 uid->type = confdata->ned2.sneq.sua_flags;
564 if (uid->type == UA_BASE_PAV_ALIAS)
565 uid->base_unit_addr = confdata->ned2.sneq.base_unit_addr;
567 uid->type = UA_BASE_DEVICE;
572 static struct dasd_ccw_req *dasd_eckd_build_rcd_lpm(struct dasd_device *device,
574 struct ciw *ciw, __u8 lpm)
576 struct dasd_ccw_req *cqr;
579 cqr = dasd_smalloc_request("ECKD", 1 /* RCD */, ciw->count, device);
582 DEV_MESSAGE(KERN_WARNING, device, "%s",
583 "Could not allocate RCD request");
588 ccw->cmd_code = ciw->cmd;
589 ccw->cda = (__u32)(addr_t)rcd_buffer;
590 ccw->count = ciw->count;
592 cqr->startdev = device;
593 cqr->memdev = device;
595 cqr->expires = 10*HZ;
597 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
599 cqr->buildclk = get_clock();
600 cqr->status = DASD_CQR_FILLED;
604 static int dasd_eckd_read_conf_lpm(struct dasd_device *device,
606 int *rcd_buffer_size, __u8 lpm)
609 char *rcd_buf = NULL;
611 struct dasd_ccw_req *cqr;
614 * scan for RCD command in extended SenseID data
616 ciw = ccw_device_get_ciw(device->cdev, CIW_TYPE_RCD);
617 if (!ciw || ciw->cmd == 0) {
621 rcd_buf = kzalloc(ciw->count, GFP_KERNEL | GFP_DMA);
626 cqr = dasd_eckd_build_rcd_lpm(device, rcd_buf, ciw, lpm);
631 ret = dasd_sleep_on(cqr);
633 * on success we update the user input parms
635 dasd_sfree_request(cqr, cqr->memdev);
639 *rcd_buffer_size = ciw->count;
640 *rcd_buffer = rcd_buf;
645 *rcd_buffer_size = 0;
650 dasd_eckd_read_conf(struct dasd_device *device)
653 int conf_len, conf_data_saved;
656 struct dasd_eckd_private *private;
657 struct dasd_eckd_path *path_data;
659 private = (struct dasd_eckd_private *) device->private;
660 path_data = (struct dasd_eckd_path *) &private->path_data;
661 path_data->opm = ccw_device_get_path_mask(device->cdev);
665 /* get configuration data per operational path */
666 for (lpm = 0x80; lpm; lpm>>= 1) {
667 if (lpm & path_data->opm){
668 rc = dasd_eckd_read_conf_lpm(device, &conf_data,
670 if (rc && rc != -EOPNOTSUPP) { /* -EOPNOTSUPP is ok */
671 MESSAGE(KERN_WARNING,
672 "Read configuration data returned "
676 if (conf_data == NULL) {
677 MESSAGE(KERN_WARNING, "%s", "No configuration "
679 continue; /* no error */
681 if (conf_len != sizeof(struct dasd_eckd_confdata)) {
682 MESSAGE(KERN_WARNING,
683 "sizes of configuration data mismatch"
684 "%d (read) vs %ld (expected)",
686 sizeof(struct dasd_eckd_confdata));
688 continue; /* no error */
690 /* save first valid configuration data */
691 if (!conf_data_saved){
692 memcpy(&private->conf_data, conf_data,
693 sizeof(struct dasd_eckd_confdata));
696 switch (((char *)conf_data)[242] & 0x07){
698 path_data->npm |= lpm;
701 path_data->ppm |= lpm;
710 static int dasd_eckd_read_features(struct dasd_device *device)
712 struct dasd_psf_prssd_data *prssdp;
713 struct dasd_rssd_features *features;
714 struct dasd_ccw_req *cqr;
717 struct dasd_eckd_private *private;
719 private = (struct dasd_eckd_private *) device->private;
720 cqr = dasd_smalloc_request(dasd_eckd_discipline.name,
721 1 /* PSF */ + 1 /* RSSD */ ,
722 (sizeof(struct dasd_psf_prssd_data) +
723 sizeof(struct dasd_rssd_features)),
726 DEV_MESSAGE(KERN_WARNING, device, "%s",
727 "Could not allocate initialization request");
730 cqr->startdev = device;
731 cqr->memdev = device;
733 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
735 cqr->expires = 10 * HZ;
737 /* Prepare for Read Subsystem Data */
738 prssdp = (struct dasd_psf_prssd_data *) cqr->data;
739 memset(prssdp, 0, sizeof(struct dasd_psf_prssd_data));
740 prssdp->order = PSF_ORDER_PRSSD;
741 prssdp->suborder = 0x41; /* Read Feature Codes */
742 /* all other bytes of prssdp must be zero */
745 ccw->cmd_code = DASD_ECKD_CCW_PSF;
746 ccw->count = sizeof(struct dasd_psf_prssd_data);
747 ccw->flags |= CCW_FLAG_CC;
748 ccw->cda = (__u32)(addr_t) prssdp;
750 /* Read Subsystem Data - feature codes */
751 features = (struct dasd_rssd_features *) (prssdp + 1);
752 memset(features, 0, sizeof(struct dasd_rssd_features));
755 ccw->cmd_code = DASD_ECKD_CCW_RSSD;
756 ccw->count = sizeof(struct dasd_rssd_features);
757 ccw->cda = (__u32)(addr_t) features;
759 cqr->buildclk = get_clock();
760 cqr->status = DASD_CQR_FILLED;
761 rc = dasd_sleep_on(cqr);
763 prssdp = (struct dasd_psf_prssd_data *) cqr->data;
764 features = (struct dasd_rssd_features *) (prssdp + 1);
765 memcpy(&private->features, features,
766 sizeof(struct dasd_rssd_features));
768 dasd_sfree_request(cqr, cqr->memdev);
774 * Build CP for Perform Subsystem Function - SSC.
776 static struct dasd_ccw_req *dasd_eckd_build_psf_ssc(struct dasd_device *device)
778 struct dasd_ccw_req *cqr;
779 struct dasd_psf_ssc_data *psf_ssc_data;
782 cqr = dasd_smalloc_request("ECKD", 1 /* PSF */ ,
783 sizeof(struct dasd_psf_ssc_data),
787 DEV_MESSAGE(KERN_WARNING, device, "%s",
788 "Could not allocate PSF-SSC request");
791 psf_ssc_data = (struct dasd_psf_ssc_data *)cqr->data;
792 psf_ssc_data->order = PSF_ORDER_SSC;
793 psf_ssc_data->suborder = 0x88;
794 psf_ssc_data->reserved[0] = 0x88;
797 ccw->cmd_code = DASD_ECKD_CCW_PSF;
798 ccw->cda = (__u32)(addr_t)psf_ssc_data;
801 cqr->startdev = device;
802 cqr->memdev = device;
804 cqr->expires = 10*HZ;
805 cqr->buildclk = get_clock();
806 cqr->status = DASD_CQR_FILLED;
811 * Perform Subsystem Function.
812 * It is necessary to trigger CIO for channel revalidation since this
813 * call might change behaviour of DASD devices.
816 dasd_eckd_psf_ssc(struct dasd_device *device)
818 struct dasd_ccw_req *cqr;
821 cqr = dasd_eckd_build_psf_ssc(device);
825 rc = dasd_sleep_on(cqr);
827 /* trigger CIO to reprobe devices */
828 css_schedule_reprobe();
829 dasd_sfree_request(cqr, cqr->memdev);
834 * Valide storage server of current device.
836 static int dasd_eckd_validate_server(struct dasd_device *device)
839 struct dasd_eckd_private *private;
841 /* Currently PAV is the only reason to 'validate' server on LPAR */
842 if (dasd_nopav || MACHINE_IS_VM)
845 rc = dasd_eckd_psf_ssc(device);
846 /* may be requested feature is not available on server,
847 * therefore just report error and go ahead */
848 private = (struct dasd_eckd_private *) device->private;
849 DEV_MESSAGE(KERN_INFO, device,
850 "PSF-SSC on storage subsystem %s.%s.%04x returned rc=%d",
851 private->uid.vendor, private->uid.serial,
852 private->uid.ssid, rc);
853 /* RE-Read Configuration Data */
854 return dasd_eckd_read_conf(device);
858 * Check device characteristics.
859 * If the device is accessible using ECKD discipline, the device is enabled.
862 dasd_eckd_check_characteristics(struct dasd_device *device)
864 struct dasd_eckd_private *private;
865 struct dasd_block *block;
869 private = (struct dasd_eckd_private *) device->private;
870 if (private == NULL) {
871 private = kzalloc(sizeof(struct dasd_eckd_private),
872 GFP_KERNEL | GFP_DMA);
873 if (private == NULL) {
874 DEV_MESSAGE(KERN_WARNING, device, "%s",
875 "memory allocation failed for private "
879 device->private = (void *) private;
881 /* Invalidate status of initial analysis. */
882 private->init_cqr_status = -1;
883 /* Set default cache operations. */
884 private->attrib.operation = DASD_NORMAL_CACHE;
885 private->attrib.nr_cyl = 0;
887 /* Read Configuration Data */
888 rc = dasd_eckd_read_conf(device);
892 /* Generate device unique id and register in devmap */
893 rc = dasd_eckd_generate_uid(device, &private->uid);
896 dasd_set_uid(device->cdev, &private->uid);
898 if (private->uid.type == UA_BASE_DEVICE) {
899 block = dasd_alloc_block();
901 DEV_MESSAGE(KERN_WARNING, device, "%s",
902 "could not allocate dasd block structure");
906 device->block = block;
907 block->base = device;
910 /* register lcu with alias handling, enable PAV if this is a new lcu */
911 is_known = dasd_alias_make_device_known_to_lcu(device);
918 rc = dasd_eckd_validate_server(device); /* will switch pav on */
923 /* Read Feature Codes */
924 rc = dasd_eckd_read_features(device);
928 /* Read Device Characteristics */
929 rdc_data = (void *) &(private->rdc_data);
930 memset(rdc_data, 0, sizeof(rdc_data));
931 rc = dasd_generic_read_dev_chars(device, "ECKD", &rdc_data, 64);
933 DEV_MESSAGE(KERN_WARNING, device,
934 "Read device characteristics returned "
938 DEV_MESSAGE(KERN_INFO, device,
939 "%04X/%02X(CU:%04X/%02X) Cyl:%d Head:%d Sec:%d",
940 private->rdc_data.dev_type,
941 private->rdc_data.dev_model,
942 private->rdc_data.cu_type,
943 private->rdc_data.cu_model.model,
944 private->rdc_data.no_cyl,
945 private->rdc_data.trk_per_cyl,
946 private->rdc_data.sec_per_trk);
950 dasd_alias_disconnect_device_from_lcu(device);
952 dasd_free_block(device->block);
953 device->block = NULL;
955 kfree(device->private);
956 device->private = NULL;
960 static void dasd_eckd_uncheck_device(struct dasd_device *device)
962 dasd_alias_disconnect_device_from_lcu(device);
965 static struct dasd_ccw_req *
966 dasd_eckd_analysis_ccw(struct dasd_device *device)
968 struct dasd_eckd_private *private;
969 struct eckd_count *count_data;
970 struct LO_eckd_data *LO_data;
971 struct dasd_ccw_req *cqr;
973 int cplength, datasize;
976 private = (struct dasd_eckd_private *) device->private;
979 datasize = sizeof(struct DE_eckd_data) + 2*sizeof(struct LO_eckd_data);
980 cqr = dasd_smalloc_request(dasd_eckd_discipline.name,
981 cplength, datasize, device);
985 /* Define extent for the first 3 tracks. */
986 define_extent(ccw++, cqr->data, 0, 2,
987 DASD_ECKD_CCW_READ_COUNT, device);
988 LO_data = cqr->data + sizeof(struct DE_eckd_data);
989 /* Locate record for the first 4 records on track 0. */
990 ccw[-1].flags |= CCW_FLAG_CC;
991 locate_record(ccw++, LO_data++, 0, 0, 4,
992 DASD_ECKD_CCW_READ_COUNT, device, 0);
994 count_data = private->count_area;
995 for (i = 0; i < 4; i++) {
996 ccw[-1].flags |= CCW_FLAG_CC;
997 ccw->cmd_code = DASD_ECKD_CCW_READ_COUNT;
1000 ccw->cda = (__u32)(addr_t) count_data;
1005 /* Locate record for the first record on track 2. */
1006 ccw[-1].flags |= CCW_FLAG_CC;
1007 locate_record(ccw++, LO_data++, 2, 0, 1,
1008 DASD_ECKD_CCW_READ_COUNT, device, 0);
1009 /* Read count ccw. */
1010 ccw[-1].flags |= CCW_FLAG_CC;
1011 ccw->cmd_code = DASD_ECKD_CCW_READ_COUNT;
1014 ccw->cda = (__u32)(addr_t) count_data;
1017 cqr->startdev = device;
1018 cqr->memdev = device;
1020 cqr->buildclk = get_clock();
1021 cqr->status = DASD_CQR_FILLED;
1026 * This is the callback function for the init_analysis cqr. It saves
1027 * the status of the initial analysis ccw before it frees it and kicks
1028 * the device to continue the startup sequence. This will call
1029 * dasd_eckd_do_analysis again (if the devices has not been marked
1030 * for deletion in the meantime).
1033 dasd_eckd_analysis_callback(struct dasd_ccw_req *init_cqr, void *data)
1035 struct dasd_eckd_private *private;
1036 struct dasd_device *device;
1038 device = init_cqr->startdev;
1039 private = (struct dasd_eckd_private *) device->private;
1040 private->init_cqr_status = init_cqr->status;
1041 dasd_sfree_request(init_cqr, device);
1042 dasd_kick_device(device);
1046 dasd_eckd_start_analysis(struct dasd_block *block)
1048 struct dasd_eckd_private *private;
1049 struct dasd_ccw_req *init_cqr;
1051 private = (struct dasd_eckd_private *) block->base->private;
1052 init_cqr = dasd_eckd_analysis_ccw(block->base);
1053 if (IS_ERR(init_cqr))
1054 return PTR_ERR(init_cqr);
1055 init_cqr->callback = dasd_eckd_analysis_callback;
1056 init_cqr->callback_data = NULL;
1057 init_cqr->expires = 5*HZ;
1058 dasd_add_request_head(init_cqr);
1063 dasd_eckd_end_analysis(struct dasd_block *block)
1065 struct dasd_device *device;
1066 struct dasd_eckd_private *private;
1067 struct eckd_count *count_area;
1068 unsigned int sb, blk_per_trk;
1071 device = block->base;
1072 private = (struct dasd_eckd_private *) device->private;
1073 status = private->init_cqr_status;
1074 private->init_cqr_status = -1;
1075 if (status != DASD_CQR_DONE) {
1076 DEV_MESSAGE(KERN_WARNING, device, "%s",
1077 "volume analysis returned unformatted disk");
1078 return -EMEDIUMTYPE;
1081 private->uses_cdl = 1;
1082 /* Calculate number of blocks/records per track. */
1083 blk_per_trk = recs_per_track(&private->rdc_data, 0, block->bp_block);
1084 /* Check Track 0 for Compatible Disk Layout */
1086 for (i = 0; i < 3; i++) {
1087 if (private->count_area[i].kl != 4 ||
1088 private->count_area[i].dl != dasd_eckd_cdl_reclen(i) - 4) {
1089 private->uses_cdl = 0;
1094 count_area = &private->count_area[4];
1096 if (private->uses_cdl == 0) {
1097 for (i = 0; i < 5; i++) {
1098 if ((private->count_area[i].kl != 0) ||
1099 (private->count_area[i].dl !=
1100 private->count_area[0].dl))
1104 count_area = &private->count_area[0];
1106 if (private->count_area[3].record == 1)
1107 DEV_MESSAGE(KERN_WARNING, device, "%s",
1108 "Trk 0: no records after VTOC!");
1110 if (count_area != NULL && count_area->kl == 0) {
1111 /* we found notthing violating our disk layout */
1112 if (dasd_check_blocksize(count_area->dl) == 0)
1113 block->bp_block = count_area->dl;
1115 if (block->bp_block == 0) {
1116 DEV_MESSAGE(KERN_WARNING, device, "%s",
1117 "Volume has incompatible disk layout");
1118 return -EMEDIUMTYPE;
1120 block->s2b_shift = 0; /* bits to shift 512 to get a block */
1121 for (sb = 512; sb < block->bp_block; sb = sb << 1)
1124 blk_per_trk = recs_per_track(&private->rdc_data, 0, block->bp_block);
1125 block->blocks = (private->rdc_data.no_cyl *
1126 private->rdc_data.trk_per_cyl *
1129 DEV_MESSAGE(KERN_INFO, device,
1130 "(%dkB blks): %dkB at %dkB/trk %s",
1131 (block->bp_block >> 10),
1132 ((private->rdc_data.no_cyl *
1133 private->rdc_data.trk_per_cyl *
1134 blk_per_trk * (block->bp_block >> 9)) >> 1),
1135 ((blk_per_trk * block->bp_block) >> 10),
1137 "compatible disk layout" : "linux disk layout");
1142 static int dasd_eckd_do_analysis(struct dasd_block *block)
1144 struct dasd_eckd_private *private;
1146 private = (struct dasd_eckd_private *) block->base->private;
1147 if (private->init_cqr_status < 0)
1148 return dasd_eckd_start_analysis(block);
1150 return dasd_eckd_end_analysis(block);
1153 static int dasd_eckd_ready_to_online(struct dasd_device *device)
1155 return dasd_alias_add_device(device);
1158 static int dasd_eckd_online_to_ready(struct dasd_device *device)
1160 return dasd_alias_remove_device(device);
1164 dasd_eckd_fill_geometry(struct dasd_block *block, struct hd_geometry *geo)
1166 struct dasd_eckd_private *private;
1168 private = (struct dasd_eckd_private *) block->base->private;
1169 if (dasd_check_blocksize(block->bp_block) == 0) {
1170 geo->sectors = recs_per_track(&private->rdc_data,
1171 0, block->bp_block);
1173 geo->cylinders = private->rdc_data.no_cyl;
1174 geo->heads = private->rdc_data.trk_per_cyl;
1178 static struct dasd_ccw_req *
1179 dasd_eckd_format_device(struct dasd_device * device,
1180 struct format_data_t * fdata)
1182 struct dasd_eckd_private *private;
1183 struct dasd_ccw_req *fcp;
1184 struct eckd_count *ect;
1188 int cplength, datasize;
1191 private = (struct dasd_eckd_private *) device->private;
1192 rpt = recs_per_track(&private->rdc_data, 0, fdata->blksize);
1193 cyl = fdata->start_unit / private->rdc_data.trk_per_cyl;
1194 head = fdata->start_unit % private->rdc_data.trk_per_cyl;
1196 /* Sanity checks. */
1197 if (fdata->start_unit >=
1198 (private->rdc_data.no_cyl * private->rdc_data.trk_per_cyl)) {
1199 DEV_MESSAGE(KERN_INFO, device, "Track no %d too big!",
1201 return ERR_PTR(-EINVAL);
1203 if (fdata->start_unit > fdata->stop_unit) {
1204 DEV_MESSAGE(KERN_INFO, device, "Track %d reached! ending.",
1206 return ERR_PTR(-EINVAL);
1208 if (dasd_check_blocksize(fdata->blksize) != 0) {
1209 DEV_MESSAGE(KERN_WARNING, device,
1210 "Invalid blocksize %d...terminating!",
1212 return ERR_PTR(-EINVAL);
1216 * fdata->intensity is a bit string that tells us what to do:
1217 * Bit 0: write record zero
1218 * Bit 1: write home address, currently not supported
1219 * Bit 2: invalidate tracks
1220 * Bit 3: use OS/390 compatible disk layout (cdl)
1221 * Only some bit combinations do make sense.
1223 switch (fdata->intensity) {
1224 case 0x00: /* Normal format */
1225 case 0x08: /* Normal format, use cdl. */
1227 datasize = sizeof(struct DE_eckd_data) +
1228 sizeof(struct LO_eckd_data) +
1229 rpt * sizeof(struct eckd_count);
1231 case 0x01: /* Write record zero and format track. */
1232 case 0x09: /* Write record zero and format track, use cdl. */
1234 datasize = sizeof(struct DE_eckd_data) +
1235 sizeof(struct LO_eckd_data) +
1236 sizeof(struct eckd_count) +
1237 rpt * sizeof(struct eckd_count);
1239 case 0x04: /* Invalidate track. */
1240 case 0x0c: /* Invalidate track, use cdl. */
1242 datasize = sizeof(struct DE_eckd_data) +
1243 sizeof(struct LO_eckd_data) +
1244 sizeof(struct eckd_count);
1247 DEV_MESSAGE(KERN_WARNING, device, "Invalid flags 0x%x.",
1249 return ERR_PTR(-EINVAL);
1251 /* Allocate the format ccw request. */
1252 fcp = dasd_smalloc_request(dasd_eckd_discipline.name,
1253 cplength, datasize, device);
1260 switch (fdata->intensity & ~0x08) {
1261 case 0x00: /* Normal format. */
1262 define_extent(ccw++, (struct DE_eckd_data *) data,
1263 fdata->start_unit, fdata->start_unit,
1264 DASD_ECKD_CCW_WRITE_CKD, device);
1265 data += sizeof(struct DE_eckd_data);
1266 ccw[-1].flags |= CCW_FLAG_CC;
1267 locate_record(ccw++, (struct LO_eckd_data *) data,
1268 fdata->start_unit, 0, rpt,
1269 DASD_ECKD_CCW_WRITE_CKD, device,
1271 data += sizeof(struct LO_eckd_data);
1273 case 0x01: /* Write record zero + format track. */
1274 define_extent(ccw++, (struct DE_eckd_data *) data,
1275 fdata->start_unit, fdata->start_unit,
1276 DASD_ECKD_CCW_WRITE_RECORD_ZERO,
1278 data += sizeof(struct DE_eckd_data);
1279 ccw[-1].flags |= CCW_FLAG_CC;
1280 locate_record(ccw++, (struct LO_eckd_data *) data,
1281 fdata->start_unit, 0, rpt + 1,
1282 DASD_ECKD_CCW_WRITE_RECORD_ZERO, device,
1283 device->block->bp_block);
1284 data += sizeof(struct LO_eckd_data);
1286 case 0x04: /* Invalidate track. */
1287 define_extent(ccw++, (struct DE_eckd_data *) data,
1288 fdata->start_unit, fdata->start_unit,
1289 DASD_ECKD_CCW_WRITE_CKD, device);
1290 data += sizeof(struct DE_eckd_data);
1291 ccw[-1].flags |= CCW_FLAG_CC;
1292 locate_record(ccw++, (struct LO_eckd_data *) data,
1293 fdata->start_unit, 0, 1,
1294 DASD_ECKD_CCW_WRITE_CKD, device, 8);
1295 data += sizeof(struct LO_eckd_data);
1298 if (fdata->intensity & 0x01) { /* write record zero */
1299 ect = (struct eckd_count *) data;
1300 data += sizeof(struct eckd_count);
1306 ccw[-1].flags |= CCW_FLAG_CC;
1307 ccw->cmd_code = DASD_ECKD_CCW_WRITE_RECORD_ZERO;
1308 ccw->flags = CCW_FLAG_SLI;
1310 ccw->cda = (__u32)(addr_t) ect;
1313 if ((fdata->intensity & ~0x08) & 0x04) { /* erase track */
1314 ect = (struct eckd_count *) data;
1315 data += sizeof(struct eckd_count);
1321 ccw[-1].flags |= CCW_FLAG_CC;
1322 ccw->cmd_code = DASD_ECKD_CCW_WRITE_CKD;
1323 ccw->flags = CCW_FLAG_SLI;
1325 ccw->cda = (__u32)(addr_t) ect;
1326 } else { /* write remaining records */
1327 for (i = 0; i < rpt; i++) {
1328 ect = (struct eckd_count *) data;
1329 data += sizeof(struct eckd_count);
1332 ect->record = i + 1;
1334 ect->dl = fdata->blksize;
1335 /* Check for special tracks 0-1 when formatting CDL */
1336 if ((fdata->intensity & 0x08) &&
1337 fdata->start_unit == 0) {
1340 ect->dl = sizes_trk0[i] - 4;
1343 if ((fdata->intensity & 0x08) &&
1344 fdata->start_unit == 1) {
1346 ect->dl = LABEL_SIZE - 44;
1348 ccw[-1].flags |= CCW_FLAG_CC;
1349 ccw->cmd_code = DASD_ECKD_CCW_WRITE_CKD;
1350 ccw->flags = CCW_FLAG_SLI;
1352 ccw->cda = (__u32)(addr_t) ect;
1356 fcp->startdev = device;
1357 fcp->memdev = device;
1358 clear_bit(DASD_CQR_FLAGS_USE_ERP, &fcp->flags);
1359 fcp->retries = 5; /* set retry counter to enable default ERP */
1360 fcp->buildclk = get_clock();
1361 fcp->status = DASD_CQR_FILLED;
1365 static void dasd_eckd_handle_terminated_request(struct dasd_ccw_req *cqr)
1367 cqr->status = DASD_CQR_FILLED;
1368 if (cqr->block && (cqr->startdev != cqr->block->base)) {
1369 dasd_eckd_reset_ccw_to_base_io(cqr);
1370 cqr->startdev = cqr->block->base;
1374 static dasd_erp_fn_t
1375 dasd_eckd_erp_action(struct dasd_ccw_req * cqr)
1377 struct dasd_device *device = (struct dasd_device *) cqr->startdev;
1378 struct ccw_device *cdev = device->cdev;
1380 switch (cdev->id.cu_type) {
1385 return dasd_3990_erp_action;
1389 return dasd_default_erp_action;
1393 static dasd_erp_fn_t
1394 dasd_eckd_erp_postaction(struct dasd_ccw_req * cqr)
1396 return dasd_default_erp_postaction;
1400 static void dasd_eckd_handle_unsolicited_interrupt(struct dasd_device *device,
1405 /* first of all check for state change pending interrupt */
1406 mask = DEV_STAT_ATTENTION | DEV_STAT_DEV_END | DEV_STAT_UNIT_EXCEP;
1407 if ((irb->scsw.cmd.dstat & mask) == mask) {
1408 dasd_generic_handle_state_change(device);
1412 /* summary unit check */
1413 if ((irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) &&
1414 (irb->ecw[7] == 0x0D)) {
1415 dasd_alias_handle_summary_unit_check(device, irb);
1420 /* service information message SIM */
1421 if (irb->esw.esw0.erw.cons && (irb->ecw[27] & DASD_SENSE_BIT_0) &&
1422 ((irb->ecw[6] & DASD_SIM_SENSE) == DASD_SIM_SENSE)) {
1423 dasd_3990_erp_handle_sim(device, irb->ecw);
1424 dasd_schedule_device_bh(device);
1428 /* just report other unsolicited interrupts */
1429 DEV_MESSAGE(KERN_DEBUG, device, "%s",
1430 "unsolicited interrupt received");
1431 device->discipline->dump_sense(device, NULL, irb);
1432 dasd_schedule_device_bh(device);
1437 static struct dasd_ccw_req *dasd_eckd_build_cp(struct dasd_device *startdev,
1438 struct dasd_block *block,
1439 struct request *req)
1441 struct dasd_eckd_private *private;
1442 unsigned long *idaws;
1443 struct LO_eckd_data *LO_data;
1444 struct dasd_ccw_req *cqr;
1446 struct req_iterator iter;
1449 unsigned int blksize, blk_per_trk, off;
1450 int count, cidaw, cplength, datasize;
1451 sector_t recid, first_rec, last_rec;
1452 sector_t first_trk, last_trk;
1453 unsigned int first_offs, last_offs;
1454 unsigned char cmd, rcmd;
1456 struct dasd_device *basedev;
1458 basedev = block->base;
1459 private = (struct dasd_eckd_private *) basedev->private;
1460 if (rq_data_dir(req) == READ)
1461 cmd = DASD_ECKD_CCW_READ_MT;
1462 else if (rq_data_dir(req) == WRITE)
1463 cmd = DASD_ECKD_CCW_WRITE_MT;
1465 return ERR_PTR(-EINVAL);
1466 /* Calculate number of blocks/records per track. */
1467 blksize = block->bp_block;
1468 blk_per_trk = recs_per_track(&private->rdc_data, 0, blksize);
1469 /* Calculate record id of first and last block. */
1470 first_rec = first_trk = req->sector >> block->s2b_shift;
1471 first_offs = sector_div(first_trk, blk_per_trk);
1472 last_rec = last_trk =
1473 (req->sector + req->nr_sectors - 1) >> block->s2b_shift;
1474 last_offs = sector_div(last_trk, blk_per_trk);
1475 /* Check struct bio and count the number of blocks for the request. */
1478 rq_for_each_segment(bv, req, iter) {
1479 if (bv->bv_len & (blksize - 1))
1480 /* Eckd can only do full blocks. */
1481 return ERR_PTR(-EINVAL);
1482 count += bv->bv_len >> (block->s2b_shift + 9);
1483 #if defined(CONFIG_64BIT)
1484 if (idal_is_needed (page_address(bv->bv_page), bv->bv_len))
1485 cidaw += bv->bv_len >> (block->s2b_shift + 9);
1489 if (count != last_rec - first_rec + 1)
1490 return ERR_PTR(-EINVAL);
1492 /* use the prefix command if available */
1493 use_prefix = private->features.feature[8] & 0x01;
1495 /* 1x prefix + number of blocks */
1496 cplength = 2 + count;
1497 /* 1x prefix + cidaws*sizeof(long) */
1498 datasize = sizeof(struct PFX_eckd_data) +
1499 sizeof(struct LO_eckd_data) +
1500 cidaw * sizeof(unsigned long);
1502 /* 1x define extent + 1x locate record + number of blocks */
1503 cplength = 2 + count;
1504 /* 1x define extent + 1x locate record + cidaws*sizeof(long) */
1505 datasize = sizeof(struct DE_eckd_data) +
1506 sizeof(struct LO_eckd_data) +
1507 cidaw * sizeof(unsigned long);
1509 /* Find out the number of additional locate record ccws for cdl. */
1510 if (private->uses_cdl && first_rec < 2*blk_per_trk) {
1511 if (last_rec >= 2*blk_per_trk)
1512 count = 2*blk_per_trk - first_rec;
1514 datasize += count*sizeof(struct LO_eckd_data);
1516 /* Allocate the ccw request. */
1517 cqr = dasd_smalloc_request(dasd_eckd_discipline.name,
1518 cplength, datasize, startdev);
1522 /* First ccw is define extent or prefix. */
1524 if (prefix(ccw++, cqr->data, first_trk,
1525 last_trk, cmd, basedev, startdev) == -EAGAIN) {
1526 /* Clock not in sync and XRC is enabled.
1529 dasd_sfree_request(cqr, startdev);
1530 return ERR_PTR(-EAGAIN);
1532 idaws = (unsigned long *) (cqr->data +
1533 sizeof(struct PFX_eckd_data));
1535 if (define_extent(ccw++, cqr->data, first_trk,
1536 last_trk, cmd, startdev) == -EAGAIN) {
1537 /* Clock not in sync and XRC is enabled.
1540 dasd_sfree_request(cqr, startdev);
1541 return ERR_PTR(-EAGAIN);
1543 idaws = (unsigned long *) (cqr->data +
1544 sizeof(struct DE_eckd_data));
1546 /* Build locate_record+read/write/ccws. */
1547 LO_data = (struct LO_eckd_data *) (idaws + cidaw);
1549 if (private->uses_cdl == 0 || recid > 2*blk_per_trk) {
1550 /* Only standard blocks so there is just one locate record. */
1551 ccw[-1].flags |= CCW_FLAG_CC;
1552 locate_record(ccw++, LO_data++, first_trk, first_offs + 1,
1553 last_rec - recid + 1, cmd, basedev, blksize);
1555 rq_for_each_segment(bv, req, iter) {
1556 dst = page_address(bv->bv_page) + bv->bv_offset;
1557 if (dasd_page_cache) {
1558 char *copy = kmem_cache_alloc(dasd_page_cache,
1559 GFP_DMA | __GFP_NOWARN);
1560 if (copy && rq_data_dir(req) == WRITE)
1561 memcpy(copy + bv->bv_offset, dst, bv->bv_len);
1563 dst = copy + bv->bv_offset;
1565 for (off = 0; off < bv->bv_len; off += blksize) {
1566 sector_t trkid = recid;
1567 unsigned int recoffs = sector_div(trkid, blk_per_trk);
1570 /* Locate record for cdl special block ? */
1571 if (private->uses_cdl && recid < 2*blk_per_trk) {
1572 if (dasd_eckd_cdl_special(blk_per_trk, recid)){
1574 count = dasd_eckd_cdl_reclen(recid);
1575 if (count < blksize &&
1576 rq_data_dir(req) == READ)
1577 memset(dst + count, 0xe5,
1580 ccw[-1].flags |= CCW_FLAG_CC;
1581 locate_record(ccw++, LO_data++,
1583 1, rcmd, basedev, count);
1585 /* Locate record for standard blocks ? */
1586 if (private->uses_cdl && recid == 2*blk_per_trk) {
1587 ccw[-1].flags |= CCW_FLAG_CC;
1588 locate_record(ccw++, LO_data++,
1590 last_rec - recid + 1,
1591 cmd, basedev, count);
1593 /* Read/write ccw. */
1594 ccw[-1].flags |= CCW_FLAG_CC;
1595 ccw->cmd_code = rcmd;
1597 if (idal_is_needed(dst, blksize)) {
1598 ccw->cda = (__u32)(addr_t) idaws;
1599 ccw->flags = CCW_FLAG_IDA;
1600 idaws = idal_create_words(idaws, dst, blksize);
1602 ccw->cda = (__u32)(addr_t) dst;
1610 if (req->cmd_flags & REQ_FAILFAST)
1611 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
1612 cqr->startdev = startdev;
1613 cqr->memdev = startdev;
1615 cqr->expires = 5 * 60 * HZ; /* 5 minutes */
1616 cqr->lpm = private->path_data.ppm;
1618 cqr->buildclk = get_clock();
1619 cqr->status = DASD_CQR_FILLED;
1624 dasd_eckd_free_cp(struct dasd_ccw_req *cqr, struct request *req)
1626 struct dasd_eckd_private *private;
1628 struct req_iterator iter;
1631 unsigned int blksize, blk_per_trk, off;
1635 if (!dasd_page_cache)
1637 private = (struct dasd_eckd_private *) cqr->block->base->private;
1638 blksize = cqr->block->bp_block;
1639 blk_per_trk = recs_per_track(&private->rdc_data, 0, blksize);
1640 recid = req->sector >> cqr->block->s2b_shift;
1642 /* Skip over define extent & locate record. */
1644 if (private->uses_cdl == 0 || recid > 2*blk_per_trk)
1646 rq_for_each_segment(bv, req, iter) {
1647 dst = page_address(bv->bv_page) + bv->bv_offset;
1648 for (off = 0; off < bv->bv_len; off += blksize) {
1649 /* Skip locate record. */
1650 if (private->uses_cdl && recid <= 2*blk_per_trk)
1653 if (ccw->flags & CCW_FLAG_IDA)
1654 cda = *((char **)((addr_t) ccw->cda));
1656 cda = (char *)((addr_t) ccw->cda);
1658 if (rq_data_dir(req) == READ)
1659 memcpy(dst, cda, bv->bv_len);
1660 kmem_cache_free(dasd_page_cache,
1661 (void *)((addr_t)cda & PAGE_MASK));
1670 status = cqr->status == DASD_CQR_DONE;
1671 dasd_sfree_request(cqr, cqr->memdev);
1676 * Modify ccw chain in cqr so it can be started on a base device.
1678 * Note that this is not enough to restart the cqr!
1679 * Either reset cqr->startdev as well (summary unit check handling)
1680 * or restart via separate cqr (as in ERP handling).
1682 void dasd_eckd_reset_ccw_to_base_io(struct dasd_ccw_req *cqr)
1685 struct PFX_eckd_data *pfxdata;
1688 pfxdata = cqr->data;
1690 if (ccw->cmd_code == DASD_ECKD_CCW_PFX) {
1691 pfxdata->validity.verify_base = 0;
1692 pfxdata->validity.hyper_pav = 0;
1696 #define DASD_ECKD_CHANQ_MAX_SIZE 4
1698 static struct dasd_ccw_req *dasd_eckd_build_alias_cp(struct dasd_device *base,
1699 struct dasd_block *block,
1700 struct request *req)
1702 struct dasd_eckd_private *private;
1703 struct dasd_device *startdev;
1704 unsigned long flags;
1705 struct dasd_ccw_req *cqr;
1707 startdev = dasd_alias_get_start_dev(base);
1710 private = (struct dasd_eckd_private *) startdev->private;
1711 if (private->count >= DASD_ECKD_CHANQ_MAX_SIZE)
1712 return ERR_PTR(-EBUSY);
1714 spin_lock_irqsave(get_ccwdev_lock(startdev->cdev), flags);
1716 cqr = dasd_eckd_build_cp(startdev, block, req);
1719 spin_unlock_irqrestore(get_ccwdev_lock(startdev->cdev), flags);
1723 static int dasd_eckd_free_alias_cp(struct dasd_ccw_req *cqr,
1724 struct request *req)
1726 struct dasd_eckd_private *private;
1727 unsigned long flags;
1729 spin_lock_irqsave(get_ccwdev_lock(cqr->memdev->cdev), flags);
1730 private = (struct dasd_eckd_private *) cqr->memdev->private;
1732 spin_unlock_irqrestore(get_ccwdev_lock(cqr->memdev->cdev), flags);
1733 return dasd_eckd_free_cp(cqr, req);
1737 dasd_eckd_fill_info(struct dasd_device * device,
1738 struct dasd_information2_t * info)
1740 struct dasd_eckd_private *private;
1742 private = (struct dasd_eckd_private *) device->private;
1743 info->label_block = 2;
1744 info->FBA_layout = private->uses_cdl ? 0 : 1;
1745 info->format = private->uses_cdl ? DASD_FORMAT_CDL : DASD_FORMAT_LDL;
1746 info->characteristics_size = sizeof(struct dasd_eckd_characteristics);
1747 memcpy(info->characteristics, &private->rdc_data,
1748 sizeof(struct dasd_eckd_characteristics));
1749 info->confdata_size = sizeof(struct dasd_eckd_confdata);
1750 memcpy(info->configuration_data, &private->conf_data,
1751 sizeof(struct dasd_eckd_confdata));
1756 * SECTION: ioctl functions for eckd devices.
1760 * Release device ioctl.
1761 * Buils a channel programm to releases a prior reserved
1762 * (see dasd_eckd_reserve) device.
1765 dasd_eckd_release(struct dasd_device *device)
1767 struct dasd_ccw_req *cqr;
1770 if (!capable(CAP_SYS_ADMIN))
1773 cqr = dasd_smalloc_request(dasd_eckd_discipline.name,
1776 DEV_MESSAGE(KERN_WARNING, device, "%s",
1777 "Could not allocate initialization request");
1778 return PTR_ERR(cqr);
1780 cqr->cpaddr->cmd_code = DASD_ECKD_CCW_RELEASE;
1781 cqr->cpaddr->flags |= CCW_FLAG_SLI;
1782 cqr->cpaddr->count = 32;
1783 cqr->cpaddr->cda = (__u32)(addr_t) cqr->data;
1784 cqr->startdev = device;
1785 cqr->memdev = device;
1786 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
1787 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
1788 cqr->retries = 2; /* set retry counter to enable basic ERP */
1789 cqr->expires = 2 * HZ;
1790 cqr->buildclk = get_clock();
1791 cqr->status = DASD_CQR_FILLED;
1793 rc = dasd_sleep_on_immediatly(cqr);
1795 dasd_sfree_request(cqr, cqr->memdev);
1800 * Reserve device ioctl.
1801 * Options are set to 'synchronous wait for interrupt' and
1802 * 'timeout the request'. This leads to a terminate IO if
1803 * the interrupt is outstanding for a certain time.
1806 dasd_eckd_reserve(struct dasd_device *device)
1808 struct dasd_ccw_req *cqr;
1811 if (!capable(CAP_SYS_ADMIN))
1814 cqr = dasd_smalloc_request(dasd_eckd_discipline.name,
1817 DEV_MESSAGE(KERN_WARNING, device, "%s",
1818 "Could not allocate initialization request");
1819 return PTR_ERR(cqr);
1821 cqr->cpaddr->cmd_code = DASD_ECKD_CCW_RESERVE;
1822 cqr->cpaddr->flags |= CCW_FLAG_SLI;
1823 cqr->cpaddr->count = 32;
1824 cqr->cpaddr->cda = (__u32)(addr_t) cqr->data;
1825 cqr->startdev = device;
1826 cqr->memdev = device;
1827 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
1828 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
1829 cqr->retries = 2; /* set retry counter to enable basic ERP */
1830 cqr->expires = 2 * HZ;
1831 cqr->buildclk = get_clock();
1832 cqr->status = DASD_CQR_FILLED;
1834 rc = dasd_sleep_on_immediatly(cqr);
1836 dasd_sfree_request(cqr, cqr->memdev);
1841 * Steal lock ioctl - unconditional reserve device.
1842 * Buils a channel programm to break a device's reservation.
1843 * (unconditional reserve)
1846 dasd_eckd_steal_lock(struct dasd_device *device)
1848 struct dasd_ccw_req *cqr;
1851 if (!capable(CAP_SYS_ADMIN))
1854 cqr = dasd_smalloc_request(dasd_eckd_discipline.name,
1857 DEV_MESSAGE(KERN_WARNING, device, "%s",
1858 "Could not allocate initialization request");
1859 return PTR_ERR(cqr);
1861 cqr->cpaddr->cmd_code = DASD_ECKD_CCW_SLCK;
1862 cqr->cpaddr->flags |= CCW_FLAG_SLI;
1863 cqr->cpaddr->count = 32;
1864 cqr->cpaddr->cda = (__u32)(addr_t) cqr->data;
1865 cqr->startdev = device;
1866 cqr->memdev = device;
1867 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
1868 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
1869 cqr->retries = 2; /* set retry counter to enable basic ERP */
1870 cqr->expires = 2 * HZ;
1871 cqr->buildclk = get_clock();
1872 cqr->status = DASD_CQR_FILLED;
1874 rc = dasd_sleep_on_immediatly(cqr);
1876 dasd_sfree_request(cqr, cqr->memdev);
1881 * Read performance statistics
1884 dasd_eckd_performance(struct dasd_device *device, void __user *argp)
1886 struct dasd_psf_prssd_data *prssdp;
1887 struct dasd_rssd_perf_stats_t *stats;
1888 struct dasd_ccw_req *cqr;
1892 cqr = dasd_smalloc_request(dasd_eckd_discipline.name,
1893 1 /* PSF */ + 1 /* RSSD */ ,
1894 (sizeof(struct dasd_psf_prssd_data) +
1895 sizeof(struct dasd_rssd_perf_stats_t)),
1898 DEV_MESSAGE(KERN_WARNING, device, "%s",
1899 "Could not allocate initialization request");
1900 return PTR_ERR(cqr);
1902 cqr->startdev = device;
1903 cqr->memdev = device;
1905 cqr->expires = 10 * HZ;
1907 /* Prepare for Read Subsystem Data */
1908 prssdp = (struct dasd_psf_prssd_data *) cqr->data;
1909 memset(prssdp, 0, sizeof(struct dasd_psf_prssd_data));
1910 prssdp->order = PSF_ORDER_PRSSD;
1911 prssdp->suborder = 0x01; /* Performance Statistics */
1912 prssdp->varies[1] = 0x01; /* Perf Statistics for the Subsystem */
1915 ccw->cmd_code = DASD_ECKD_CCW_PSF;
1916 ccw->count = sizeof(struct dasd_psf_prssd_data);
1917 ccw->flags |= CCW_FLAG_CC;
1918 ccw->cda = (__u32)(addr_t) prssdp;
1920 /* Read Subsystem Data - Performance Statistics */
1921 stats = (struct dasd_rssd_perf_stats_t *) (prssdp + 1);
1922 memset(stats, 0, sizeof(struct dasd_rssd_perf_stats_t));
1925 ccw->cmd_code = DASD_ECKD_CCW_RSSD;
1926 ccw->count = sizeof(struct dasd_rssd_perf_stats_t);
1927 ccw->cda = (__u32)(addr_t) stats;
1929 cqr->buildclk = get_clock();
1930 cqr->status = DASD_CQR_FILLED;
1931 rc = dasd_sleep_on(cqr);
1933 prssdp = (struct dasd_psf_prssd_data *) cqr->data;
1934 stats = (struct dasd_rssd_perf_stats_t *) (prssdp + 1);
1935 if (copy_to_user(argp, stats,
1936 sizeof(struct dasd_rssd_perf_stats_t)))
1939 dasd_sfree_request(cqr, cqr->memdev);
1944 * Get attributes (cache operations)
1945 * Returnes the cache attributes used in Define Extend (DE).
1948 dasd_eckd_get_attrib(struct dasd_device *device, void __user *argp)
1950 struct dasd_eckd_private *private =
1951 (struct dasd_eckd_private *)device->private;
1952 struct attrib_data_t attrib = private->attrib;
1955 if (!capable(CAP_SYS_ADMIN))
1961 if (copy_to_user(argp, (long *) &attrib,
1962 sizeof(struct attrib_data_t)))
1969 * Set attributes (cache operations)
1970 * Stores the attributes for cache operation to be used in Define Extend (DE).
1973 dasd_eckd_set_attrib(struct dasd_device *device, void __user *argp)
1975 struct dasd_eckd_private *private =
1976 (struct dasd_eckd_private *)device->private;
1977 struct attrib_data_t attrib;
1979 if (!capable(CAP_SYS_ADMIN))
1984 if (copy_from_user(&attrib, argp, sizeof(struct attrib_data_t)))
1986 private->attrib = attrib;
1988 DEV_MESSAGE(KERN_INFO, device,
1989 "cache operation mode set to %x (%i cylinder prestage)",
1990 private->attrib.operation, private->attrib.nr_cyl);
1995 dasd_eckd_ioctl(struct dasd_block *block, unsigned int cmd, void __user *argp)
1997 struct dasd_device *device = block->base;
2001 return dasd_eckd_get_attrib(device, argp);
2003 return dasd_eckd_set_attrib(device, argp);
2005 return dasd_eckd_performance(device, argp);
2007 return dasd_eckd_release(device);
2009 return dasd_eckd_reserve(device);
2011 return dasd_eckd_steal_lock(device);
2013 return -ENOIOCTLCMD;
2018 * Dump the range of CCWs into 'page' buffer
2019 * and return number of printed chars.
2022 dasd_eckd_dump_ccw_range(struct ccw1 *from, struct ccw1 *to, char *page)
2028 while (from <= to) {
2029 len += sprintf(page + len, KERN_ERR PRINTK_HEADER
2030 " CCW %p: %08X %08X DAT:",
2031 from, ((int *) from)[0], ((int *) from)[1]);
2033 /* get pointer to data (consider IDALs) */
2034 if (from->flags & CCW_FLAG_IDA)
2035 datap = (char *) *((addr_t *) (addr_t) from->cda);
2037 datap = (char *) ((addr_t) from->cda);
2039 /* dump data (max 32 bytes) */
2040 for (count = 0; count < from->count && count < 32; count++) {
2041 if (count % 8 == 0) len += sprintf(page + len, " ");
2042 if (count % 4 == 0) len += sprintf(page + len, " ");
2043 len += sprintf(page + len, "%02x", datap[count]);
2045 len += sprintf(page + len, "\n");
2052 * Print sense data and related channel program.
2053 * Parts are printed because printk buffer is only 1024 bytes.
2055 static void dasd_eckd_dump_sense(struct dasd_device *device,
2056 struct dasd_ccw_req *req, struct irb *irb)
2059 struct ccw1 *first, *last, *fail, *from, *to;
2062 page = (char *) get_zeroed_page(GFP_ATOMIC);
2064 DEV_MESSAGE(KERN_ERR, device, " %s",
2065 "No memory to dump sense data");
2068 /* dump the sense data */
2069 len = sprintf(page, KERN_ERR PRINTK_HEADER
2070 " I/O status report for device %s:\n",
2071 device->cdev->dev.bus_id);
2072 len += sprintf(page + len, KERN_ERR PRINTK_HEADER
2073 " in req: %p CS: 0x%02X DS: 0x%02X\n", req,
2074 irb->scsw.cmd.cstat, irb->scsw.cmd.dstat);
2075 len += sprintf(page + len, KERN_ERR PRINTK_HEADER
2076 " device %s: Failing CCW: %p\n",
2077 device->cdev->dev.bus_id,
2078 (void *) (addr_t) irb->scsw.cmd.cpa);
2079 if (irb->esw.esw0.erw.cons) {
2080 for (sl = 0; sl < 4; sl++) {
2081 len += sprintf(page + len, KERN_ERR PRINTK_HEADER
2082 " Sense(hex) %2d-%2d:",
2083 (8 * sl), ((8 * sl) + 7));
2085 for (sct = 0; sct < 8; sct++) {
2086 len += sprintf(page + len, " %02x",
2087 irb->ecw[8 * sl + sct]);
2089 len += sprintf(page + len, "\n");
2092 if (irb->ecw[27] & DASD_SENSE_BIT_0) {
2093 /* 24 Byte Sense Data */
2094 sprintf(page + len, KERN_ERR PRINTK_HEADER
2095 " 24 Byte: %x MSG %x, "
2096 "%s MSGb to SYSOP\n",
2097 irb->ecw[7] >> 4, irb->ecw[7] & 0x0f,
2098 irb->ecw[1] & 0x10 ? "" : "no");
2100 /* 32 Byte Sense Data */
2101 sprintf(page + len, KERN_ERR PRINTK_HEADER
2102 " 32 Byte: Format: %x "
2103 "Exception class %x\n",
2104 irb->ecw[6] & 0x0f, irb->ecw[22] >> 4);
2107 sprintf(page + len, KERN_ERR PRINTK_HEADER
2108 " SORRY - NO VALID SENSE AVAILABLE\n");
2113 /* req == NULL for unsolicited interrupts */
2114 /* dump the Channel Program (max 140 Bytes per line) */
2115 /* Count CCW and print first CCWs (maximum 1024 % 140 = 7) */
2116 first = req->cpaddr;
2117 for (last = first; last->flags & (CCW_FLAG_CC | CCW_FLAG_DC); last++);
2118 to = min(first + 6, last);
2119 len = sprintf(page, KERN_ERR PRINTK_HEADER
2120 " Related CP in req: %p\n", req);
2121 dasd_eckd_dump_ccw_range(first, to, page + len);
2124 /* print failing CCW area (maximum 4) */
2125 /* scsw->cda is either valid or zero */
2128 fail = (struct ccw1 *)(addr_t)
2129 irb->scsw.cmd.cpa; /* failing CCW */
2130 if (from < fail - 2) {
2131 from = fail - 2; /* there is a gap - print header */
2132 len += sprintf(page, KERN_ERR PRINTK_HEADER "......\n");
2134 to = min(fail + 1, last);
2135 len += dasd_eckd_dump_ccw_range(from, to, page + len);
2137 /* print last CCWs (maximum 2) */
2138 from = max(from, ++to);
2139 if (from < last - 1) {
2140 from = last - 1; /* there is a gap - print header */
2141 len += sprintf(page + len, KERN_ERR PRINTK_HEADER "......\n");
2143 len += dasd_eckd_dump_ccw_range(from, last, page + len);
2147 free_page((unsigned long) page);
2151 * max_blocks is dependent on the amount of storage that is available
2152 * in the static io buffer for each device. Currently each device has
2153 * 8192 bytes (=2 pages). For 64 bit one dasd_mchunkt_t structure has
2154 * 24 bytes, the struct dasd_ccw_req has 136 bytes and each block can use
2155 * up to 16 bytes (8 for the ccw and 8 for the idal pointer). In
2156 * addition we have one define extent ccw + 16 bytes of data and one
2157 * locate record ccw + 16 bytes of data. That makes:
2158 * (8192 - 24 - 136 - 8 - 16 - 8 - 16) / 16 = 499 blocks at maximum.
2159 * We want to fit two into the available memory so that we can immediately
2160 * start the next request if one finishes off. That makes 249.5 blocks
2161 * for one request. Give a little safety and the result is 240.
2163 static struct dasd_discipline dasd_eckd_discipline = {
2164 .owner = THIS_MODULE,
2168 .check_device = dasd_eckd_check_characteristics,
2169 .uncheck_device = dasd_eckd_uncheck_device,
2170 .do_analysis = dasd_eckd_do_analysis,
2171 .ready_to_online = dasd_eckd_ready_to_online,
2172 .online_to_ready = dasd_eckd_online_to_ready,
2173 .fill_geometry = dasd_eckd_fill_geometry,
2174 .start_IO = dasd_start_IO,
2175 .term_IO = dasd_term_IO,
2176 .handle_terminated_request = dasd_eckd_handle_terminated_request,
2177 .format_device = dasd_eckd_format_device,
2178 .erp_action = dasd_eckd_erp_action,
2179 .erp_postaction = dasd_eckd_erp_postaction,
2180 .handle_unsolicited_interrupt = dasd_eckd_handle_unsolicited_interrupt,
2181 .build_cp = dasd_eckd_build_alias_cp,
2182 .free_cp = dasd_eckd_free_alias_cp,
2183 .dump_sense = dasd_eckd_dump_sense,
2184 .fill_info = dasd_eckd_fill_info,
2185 .ioctl = dasd_eckd_ioctl,
2189 dasd_eckd_init(void)
2191 ASCEBC(dasd_eckd_discipline.ebcname, 4);
2192 return ccw_driver_register(&dasd_eckd_driver);
2196 dasd_eckd_cleanup(void)
2198 ccw_driver_unregister(&dasd_eckd_driver);
2201 module_init(dasd_eckd_init);
2202 module_exit(dasd_eckd_cleanup);