2 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
3 * Horst Hummel <Horst.Hummel@de.ibm.com>
4 * Carsten Otte <Cotte@de.ibm.com>
5 * Martin Schwidefsky <schwidefsky@de.ibm.com>
6 * Bugreports.to..: <Linux390@de.ibm.com>
7 * Copyright IBM Corp. 1999, 2009
8 * EMC Symmetrix ioctl Copyright EMC Corporation, 2008
9 * Author.........: Nigel Hislop <hislop_nigel@emc.com>
12 #define KMSG_COMPONENT "dasd-eckd"
14 #include <linux/stddef.h>
15 #include <linux/kernel.h>
16 #include <linux/slab.h>
17 #include <linux/hdreg.h> /* HDIO_GETGEO */
18 #include <linux/bio.h>
19 #include <linux/module.h>
20 #include <linux/compat.h>
21 #include <linux/init.h>
23 #include <asm/css_chars.h>
24 #include <asm/debug.h>
25 #include <asm/idals.h>
26 #include <asm/ebcdic.h>
28 #include <asm/uaccess.h>
30 #include <asm/ccwdev.h>
34 #include "dasd_eckd.h"
38 #endif /* PRINTK_HEADER */
39 #define PRINTK_HEADER "dasd(eckd):"
41 #define ECKD_C0(i) (i->home_bytes)
42 #define ECKD_F(i) (i->formula)
43 #define ECKD_F1(i) (ECKD_F(i)==0x01?(i->factors.f_0x01.f1):\
44 (i->factors.f_0x02.f1))
45 #define ECKD_F2(i) (ECKD_F(i)==0x01?(i->factors.f_0x01.f2):\
46 (i->factors.f_0x02.f2))
47 #define ECKD_F3(i) (ECKD_F(i)==0x01?(i->factors.f_0x01.f3):\
48 (i->factors.f_0x02.f3))
49 #define ECKD_F4(i) (ECKD_F(i)==0x02?(i->factors.f_0x02.f4):0)
50 #define ECKD_F5(i) (ECKD_F(i)==0x02?(i->factors.f_0x02.f5):0)
51 #define ECKD_F6(i) (i->factor6)
52 #define ECKD_F7(i) (i->factor7)
53 #define ECKD_F8(i) (i->factor8)
56 * raw track access always map to 64k in memory
57 * so it maps to 16 blocks of 4k per track
59 #define DASD_RAW_BLOCK_PER_TRACK 16
60 #define DASD_RAW_BLOCKSIZE 4096
61 /* 64k are 128 x 512 byte sectors */
62 #define DASD_RAW_SECTORS_PER_TRACK 128
64 MODULE_LICENSE("GPL");
66 static struct dasd_discipline dasd_eckd_discipline;
68 /* The ccw bus type uses this table to find devices that it sends to
70 static struct ccw_device_id dasd_eckd_ids[] = {
71 { CCW_DEVICE_DEVTYPE (0x3990, 0, 0x3390, 0), .driver_info = 0x1},
72 { CCW_DEVICE_DEVTYPE (0x2105, 0, 0x3390, 0), .driver_info = 0x2},
73 { CCW_DEVICE_DEVTYPE (0x3880, 0, 0x3380, 0), .driver_info = 0x3},
74 { CCW_DEVICE_DEVTYPE (0x3990, 0, 0x3380, 0), .driver_info = 0x4},
75 { CCW_DEVICE_DEVTYPE (0x2105, 0, 0x3380, 0), .driver_info = 0x5},
76 { CCW_DEVICE_DEVTYPE (0x9343, 0, 0x9345, 0), .driver_info = 0x6},
77 { CCW_DEVICE_DEVTYPE (0x2107, 0, 0x3390, 0), .driver_info = 0x7},
78 { CCW_DEVICE_DEVTYPE (0x2107, 0, 0x3380, 0), .driver_info = 0x8},
79 { CCW_DEVICE_DEVTYPE (0x1750, 0, 0x3390, 0), .driver_info = 0x9},
80 { CCW_DEVICE_DEVTYPE (0x1750, 0, 0x3380, 0), .driver_info = 0xa},
81 { /* end of list */ },
84 MODULE_DEVICE_TABLE(ccw, dasd_eckd_ids);
86 static struct ccw_driver dasd_eckd_driver; /* see below */
89 #define INIT_CQR_UNFORMATTED 1
90 #define INIT_CQR_ERROR 2
92 /* emergency request for reserve/release */
94 struct dasd_ccw_req cqr;
98 static DEFINE_MUTEX(dasd_reserve_mutex);
100 /* definitions for the path verification worker */
101 struct path_verification_work_data {
102 struct work_struct worker;
103 struct dasd_device *device;
104 struct dasd_ccw_req cqr;
106 __u8 rcd_buffer[DASD_ECKD_RCD_DATA_SIZE];
110 static struct path_verification_work_data *path_verification_worker;
111 static DEFINE_MUTEX(dasd_path_verification_mutex);
113 /* initial attempt at a probe function. this can be simplified once
114 * the other detection code is gone */
116 dasd_eckd_probe (struct ccw_device *cdev)
120 /* set ECKD specific ccw-device options */
121 ret = ccw_device_set_options(cdev, CCWDEV_ALLOW_FORCE |
122 CCWDEV_DO_PATHGROUP | CCWDEV_DO_MULTIPATH);
124 DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s",
125 "dasd_eckd_probe: could not set "
126 "ccw-device options");
129 ret = dasd_generic_probe(cdev, &dasd_eckd_discipline);
134 dasd_eckd_set_online(struct ccw_device *cdev)
136 return dasd_generic_set_online(cdev, &dasd_eckd_discipline);
139 static const int sizes_trk0[] = { 28, 148, 84 };
140 #define LABEL_SIZE 140
142 /* head and record addresses of count_area read in analysis ccw */
143 static const int count_area_head[] = { 0, 0, 0, 0, 2 };
144 static const int count_area_rec[] = { 1, 2, 3, 4, 1 };
146 static inline unsigned int
147 round_up_multiple(unsigned int no, unsigned int mult)
150 return (rem ? no - rem + mult : no);
153 static inline unsigned int
154 ceil_quot(unsigned int d1, unsigned int d2)
156 return (d1 + (d2 - 1)) / d2;
160 recs_per_track(struct dasd_eckd_characteristics * rdc,
161 unsigned int kl, unsigned int dl)
165 switch (rdc->dev_type) {
168 return 1499 / (15 + 7 + ceil_quot(kl + 12, 32) +
169 ceil_quot(dl + 12, 32));
171 return 1499 / (15 + ceil_quot(dl + 12, 32));
173 dn = ceil_quot(dl + 6, 232) + 1;
175 kn = ceil_quot(kl + 6, 232) + 1;
176 return 1729 / (10 + 9 + ceil_quot(kl + 6 * kn, 34) +
177 9 + ceil_quot(dl + 6 * dn, 34));
179 return 1729 / (10 + 9 + ceil_quot(dl + 6 * dn, 34));
181 dn = ceil_quot(dl + 6, 232) + 1;
183 kn = ceil_quot(kl + 6, 232) + 1;
184 return 1420 / (18 + 7 + ceil_quot(kl + 6 * kn, 34) +
185 ceil_quot(dl + 6 * dn, 34));
187 return 1420 / (18 + 7 + ceil_quot(dl + 6 * dn, 34));
192 static void set_ch_t(struct ch_t *geo, __u32 cyl, __u8 head)
194 geo->cyl = (__u16) cyl;
195 geo->head = cyl >> 16;
201 check_XRC (struct ccw1 *de_ccw,
202 struct DE_eckd_data *data,
203 struct dasd_device *device)
205 struct dasd_eckd_private *private;
208 private = (struct dasd_eckd_private *) device->private;
209 if (!private->rdc_data.facilities.XRC_supported)
212 /* switch on System Time Stamp - needed for XRC Support */
213 data->ga_extended |= 0x08; /* switch on 'Time Stamp Valid' */
214 data->ga_extended |= 0x02; /* switch on 'Extended Parameter' */
216 rc = get_sync_clock(&data->ep_sys_time);
217 /* Ignore return code if sync clock is switched off. */
218 if (rc == -EOPNOTSUPP || rc == -EACCES)
221 de_ccw->count = sizeof(struct DE_eckd_data);
222 de_ccw->flags |= CCW_FLAG_SLI;
227 define_extent(struct ccw1 *ccw, struct DE_eckd_data *data, unsigned int trk,
228 unsigned int totrk, int cmd, struct dasd_device *device)
230 struct dasd_eckd_private *private;
232 u16 heads, beghead, endhead;
235 private = (struct dasd_eckd_private *) device->private;
237 ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT;
240 ccw->cda = (__u32) __pa(data);
242 memset(data, 0, sizeof(struct DE_eckd_data));
244 case DASD_ECKD_CCW_READ_HOME_ADDRESS:
245 case DASD_ECKD_CCW_READ_RECORD_ZERO:
246 case DASD_ECKD_CCW_READ:
247 case DASD_ECKD_CCW_READ_MT:
248 case DASD_ECKD_CCW_READ_CKD:
249 case DASD_ECKD_CCW_READ_CKD_MT:
250 case DASD_ECKD_CCW_READ_KD:
251 case DASD_ECKD_CCW_READ_KD_MT:
252 case DASD_ECKD_CCW_READ_COUNT:
253 data->mask.perm = 0x1;
254 data->attributes.operation = private->attrib.operation;
256 case DASD_ECKD_CCW_WRITE:
257 case DASD_ECKD_CCW_WRITE_MT:
258 case DASD_ECKD_CCW_WRITE_KD:
259 case DASD_ECKD_CCW_WRITE_KD_MT:
260 data->mask.perm = 0x02;
261 data->attributes.operation = private->attrib.operation;
262 rc = check_XRC (ccw, data, device);
264 case DASD_ECKD_CCW_WRITE_CKD:
265 case DASD_ECKD_CCW_WRITE_CKD_MT:
266 data->attributes.operation = DASD_BYPASS_CACHE;
267 rc = check_XRC (ccw, data, device);
269 case DASD_ECKD_CCW_ERASE:
270 case DASD_ECKD_CCW_WRITE_HOME_ADDRESS:
271 case DASD_ECKD_CCW_WRITE_RECORD_ZERO:
272 data->mask.perm = 0x3;
273 data->mask.auth = 0x1;
274 data->attributes.operation = DASD_BYPASS_CACHE;
275 rc = check_XRC (ccw, data, device);
278 dev_err(&device->cdev->dev,
279 "0x%x is not a known command\n", cmd);
283 data->attributes.mode = 0x3; /* ECKD */
285 if ((private->rdc_data.cu_type == 0x2105 ||
286 private->rdc_data.cu_type == 0x2107 ||
287 private->rdc_data.cu_type == 0x1750)
288 && !(private->uses_cdl && trk < 2))
289 data->ga_extended |= 0x40; /* Regular Data Format Mode */
291 heads = private->rdc_data.trk_per_cyl;
292 begcyl = trk / heads;
293 beghead = trk % heads;
294 endcyl = totrk / heads;
295 endhead = totrk % heads;
297 /* check for sequential prestage - enhance cylinder range */
298 if (data->attributes.operation == DASD_SEQ_PRESTAGE ||
299 data->attributes.operation == DASD_SEQ_ACCESS) {
301 if (endcyl + private->attrib.nr_cyl < private->real_cyl)
302 endcyl += private->attrib.nr_cyl;
304 endcyl = (private->real_cyl - 1);
307 set_ch_t(&data->beg_ext, begcyl, beghead);
308 set_ch_t(&data->end_ext, endcyl, endhead);
312 static int check_XRC_on_prefix(struct PFX_eckd_data *pfxdata,
313 struct dasd_device *device)
315 struct dasd_eckd_private *private;
318 private = (struct dasd_eckd_private *) device->private;
319 if (!private->rdc_data.facilities.XRC_supported)
322 /* switch on System Time Stamp - needed for XRC Support */
323 pfxdata->define_extent.ga_extended |= 0x08; /* 'Time Stamp Valid' */
324 pfxdata->define_extent.ga_extended |= 0x02; /* 'Extended Parameter' */
325 pfxdata->validity.time_stamp = 1; /* 'Time Stamp Valid' */
327 rc = get_sync_clock(&pfxdata->define_extent.ep_sys_time);
328 /* Ignore return code if sync clock is switched off. */
329 if (rc == -EOPNOTSUPP || rc == -EACCES)
334 static void fill_LRE_data(struct LRE_eckd_data *data, unsigned int trk,
335 unsigned int rec_on_trk, int count, int cmd,
336 struct dasd_device *device, unsigned int reclen,
339 struct dasd_eckd_private *private;
343 private = (struct dasd_eckd_private *) device->private;
345 memset(data, 0, sizeof(*data));
348 switch (private->rdc_data.dev_type) {
350 dn = ceil_quot(reclen + 6, 232);
351 d = 9 + ceil_quot(reclen + 6 * (dn + 1), 34);
352 sector = (49 + (rec_on_trk - 1) * (10 + d)) / 8;
355 d = 7 + ceil_quot(reclen + 12, 32);
356 sector = (39 + (rec_on_trk - 1) * (8 + d)) / 7;
360 data->sector = sector;
361 /* note: meaning of count depends on the operation
362 * for record based I/O it's the number of records, but for
363 * track based I/O it's the number of tracks
367 case DASD_ECKD_CCW_WRITE_HOME_ADDRESS:
368 data->operation.orientation = 0x3;
369 data->operation.operation = 0x03;
371 case DASD_ECKD_CCW_READ_HOME_ADDRESS:
372 data->operation.orientation = 0x3;
373 data->operation.operation = 0x16;
375 case DASD_ECKD_CCW_WRITE_RECORD_ZERO:
376 data->operation.orientation = 0x1;
377 data->operation.operation = 0x03;
380 case DASD_ECKD_CCW_READ_RECORD_ZERO:
381 data->operation.orientation = 0x3;
382 data->operation.operation = 0x16;
385 case DASD_ECKD_CCW_WRITE:
386 case DASD_ECKD_CCW_WRITE_MT:
387 case DASD_ECKD_CCW_WRITE_KD:
388 case DASD_ECKD_CCW_WRITE_KD_MT:
389 data->auxiliary.length_valid = 0x1;
390 data->length = reclen;
391 data->operation.operation = 0x01;
393 case DASD_ECKD_CCW_WRITE_CKD:
394 case DASD_ECKD_CCW_WRITE_CKD_MT:
395 data->auxiliary.length_valid = 0x1;
396 data->length = reclen;
397 data->operation.operation = 0x03;
399 case DASD_ECKD_CCW_WRITE_FULL_TRACK:
400 data->operation.orientation = 0x0;
401 data->operation.operation = 0x3F;
402 data->extended_operation = 0x11;
404 data->extended_parameter_length = 0x02;
405 if (data->count > 8) {
406 data->extended_parameter[0] = 0xFF;
407 data->extended_parameter[1] = 0xFF;
408 data->extended_parameter[1] <<= (16 - count);
410 data->extended_parameter[0] = 0xFF;
411 data->extended_parameter[0] <<= (8 - count);
412 data->extended_parameter[1] = 0x00;
416 case DASD_ECKD_CCW_WRITE_TRACK_DATA:
417 data->auxiliary.length_valid = 0x1;
418 data->length = reclen; /* not tlf, as one might think */
419 data->operation.operation = 0x3F;
420 data->extended_operation = 0x23;
422 case DASD_ECKD_CCW_READ:
423 case DASD_ECKD_CCW_READ_MT:
424 case DASD_ECKD_CCW_READ_KD:
425 case DASD_ECKD_CCW_READ_KD_MT:
426 data->auxiliary.length_valid = 0x1;
427 data->length = reclen;
428 data->operation.operation = 0x06;
430 case DASD_ECKD_CCW_READ_CKD:
431 case DASD_ECKD_CCW_READ_CKD_MT:
432 data->auxiliary.length_valid = 0x1;
433 data->length = reclen;
434 data->operation.operation = 0x16;
436 case DASD_ECKD_CCW_READ_COUNT:
437 data->operation.operation = 0x06;
439 case DASD_ECKD_CCW_READ_TRACK:
440 data->operation.orientation = 0x1;
441 data->operation.operation = 0x0C;
442 data->extended_parameter_length = 0;
445 case DASD_ECKD_CCW_READ_TRACK_DATA:
446 data->auxiliary.length_valid = 0x1;
448 data->operation.operation = 0x0C;
450 case DASD_ECKD_CCW_ERASE:
451 data->length = reclen;
452 data->auxiliary.length_valid = 0x1;
453 data->operation.operation = 0x0b;
456 DBF_DEV_EVENT(DBF_ERR, device,
457 "fill LRE unknown opcode 0x%x", cmd);
460 set_ch_t(&data->seek_addr,
461 trk / private->rdc_data.trk_per_cyl,
462 trk % private->rdc_data.trk_per_cyl);
463 data->search_arg.cyl = data->seek_addr.cyl;
464 data->search_arg.head = data->seek_addr.head;
465 data->search_arg.record = rec_on_trk;
468 static int prefix_LRE(struct ccw1 *ccw, struct PFX_eckd_data *pfxdata,
469 unsigned int trk, unsigned int totrk, int cmd,
470 struct dasd_device *basedev, struct dasd_device *startdev,
471 unsigned char format, unsigned int rec_on_trk, int count,
472 unsigned int blksize, unsigned int tlf)
474 struct dasd_eckd_private *basepriv, *startpriv;
475 struct DE_eckd_data *dedata;
476 struct LRE_eckd_data *lredata;
478 u16 heads, beghead, endhead;
481 basepriv = (struct dasd_eckd_private *) basedev->private;
482 startpriv = (struct dasd_eckd_private *) startdev->private;
483 dedata = &pfxdata->define_extent;
484 lredata = &pfxdata->locate_record;
486 ccw->cmd_code = DASD_ECKD_CCW_PFX;
488 if (cmd == DASD_ECKD_CCW_WRITE_FULL_TRACK) {
489 ccw->count = sizeof(*pfxdata) + 2;
490 ccw->cda = (__u32) __pa(pfxdata);
491 memset(pfxdata, 0, sizeof(*pfxdata) + 2);
493 ccw->count = sizeof(*pfxdata);
494 ccw->cda = (__u32) __pa(pfxdata);
495 memset(pfxdata, 0, sizeof(*pfxdata));
500 DBF_DEV_EVENT(DBF_ERR, basedev,
501 "PFX LRE unknown format 0x%x", format);
505 pfxdata->format = format;
506 pfxdata->base_address = basepriv->ned->unit_addr;
507 pfxdata->base_lss = basepriv->ned->ID;
508 pfxdata->validity.define_extent = 1;
510 /* private uid is kept up to date, conf_data may be outdated */
511 if (startpriv->uid.type != UA_BASE_DEVICE) {
512 pfxdata->validity.verify_base = 1;
513 if (startpriv->uid.type == UA_HYPER_PAV_ALIAS)
514 pfxdata->validity.hyper_pav = 1;
517 /* define extend data (mostly)*/
519 case DASD_ECKD_CCW_READ_HOME_ADDRESS:
520 case DASD_ECKD_CCW_READ_RECORD_ZERO:
521 case DASD_ECKD_CCW_READ:
522 case DASD_ECKD_CCW_READ_MT:
523 case DASD_ECKD_CCW_READ_CKD:
524 case DASD_ECKD_CCW_READ_CKD_MT:
525 case DASD_ECKD_CCW_READ_KD:
526 case DASD_ECKD_CCW_READ_KD_MT:
527 case DASD_ECKD_CCW_READ_COUNT:
528 dedata->mask.perm = 0x1;
529 dedata->attributes.operation = basepriv->attrib.operation;
531 case DASD_ECKD_CCW_READ_TRACK:
532 case DASD_ECKD_CCW_READ_TRACK_DATA:
533 dedata->mask.perm = 0x1;
534 dedata->attributes.operation = basepriv->attrib.operation;
535 dedata->blk_size = 0;
537 case DASD_ECKD_CCW_WRITE:
538 case DASD_ECKD_CCW_WRITE_MT:
539 case DASD_ECKD_CCW_WRITE_KD:
540 case DASD_ECKD_CCW_WRITE_KD_MT:
541 dedata->mask.perm = 0x02;
542 dedata->attributes.operation = basepriv->attrib.operation;
543 rc = check_XRC_on_prefix(pfxdata, basedev);
545 case DASD_ECKD_CCW_WRITE_CKD:
546 case DASD_ECKD_CCW_WRITE_CKD_MT:
547 dedata->attributes.operation = DASD_BYPASS_CACHE;
548 rc = check_XRC_on_prefix(pfxdata, basedev);
550 case DASD_ECKD_CCW_ERASE:
551 case DASD_ECKD_CCW_WRITE_HOME_ADDRESS:
552 case DASD_ECKD_CCW_WRITE_RECORD_ZERO:
553 dedata->mask.perm = 0x3;
554 dedata->mask.auth = 0x1;
555 dedata->attributes.operation = DASD_BYPASS_CACHE;
556 rc = check_XRC_on_prefix(pfxdata, basedev);
558 case DASD_ECKD_CCW_WRITE_FULL_TRACK:
559 dedata->mask.perm = 0x03;
560 dedata->attributes.operation = basepriv->attrib.operation;
561 dedata->blk_size = 0;
563 case DASD_ECKD_CCW_WRITE_TRACK_DATA:
564 dedata->mask.perm = 0x02;
565 dedata->attributes.operation = basepriv->attrib.operation;
566 dedata->blk_size = blksize;
567 rc = check_XRC_on_prefix(pfxdata, basedev);
570 DBF_DEV_EVENT(DBF_ERR, basedev,
571 "PFX LRE unknown opcode 0x%x", cmd);
576 dedata->attributes.mode = 0x3; /* ECKD */
578 if ((basepriv->rdc_data.cu_type == 0x2105 ||
579 basepriv->rdc_data.cu_type == 0x2107 ||
580 basepriv->rdc_data.cu_type == 0x1750)
581 && !(basepriv->uses_cdl && trk < 2))
582 dedata->ga_extended |= 0x40; /* Regular Data Format Mode */
584 heads = basepriv->rdc_data.trk_per_cyl;
585 begcyl = trk / heads;
586 beghead = trk % heads;
587 endcyl = totrk / heads;
588 endhead = totrk % heads;
590 /* check for sequential prestage - enhance cylinder range */
591 if (dedata->attributes.operation == DASD_SEQ_PRESTAGE ||
592 dedata->attributes.operation == DASD_SEQ_ACCESS) {
594 if (endcyl + basepriv->attrib.nr_cyl < basepriv->real_cyl)
595 endcyl += basepriv->attrib.nr_cyl;
597 endcyl = (basepriv->real_cyl - 1);
600 set_ch_t(&dedata->beg_ext, begcyl, beghead);
601 set_ch_t(&dedata->end_ext, endcyl, endhead);
604 fill_LRE_data(lredata, trk, rec_on_trk, count, cmd,
605 basedev, blksize, tlf);
611 static int prefix(struct ccw1 *ccw, struct PFX_eckd_data *pfxdata,
612 unsigned int trk, unsigned int totrk, int cmd,
613 struct dasd_device *basedev, struct dasd_device *startdev)
615 return prefix_LRE(ccw, pfxdata, trk, totrk, cmd, basedev, startdev,
620 locate_record(struct ccw1 *ccw, struct LO_eckd_data *data, unsigned int trk,
621 unsigned int rec_on_trk, int no_rec, int cmd,
622 struct dasd_device * device, int reclen)
624 struct dasd_eckd_private *private;
628 private = (struct dasd_eckd_private *) device->private;
630 DBF_DEV_EVENT(DBF_INFO, device,
631 "Locate: trk %d, rec %d, no_rec %d, cmd %d, reclen %d",
632 trk, rec_on_trk, no_rec, cmd, reclen);
634 ccw->cmd_code = DASD_ECKD_CCW_LOCATE_RECORD;
637 ccw->cda = (__u32) __pa(data);
639 memset(data, 0, sizeof(struct LO_eckd_data));
642 switch (private->rdc_data.dev_type) {
644 dn = ceil_quot(reclen + 6, 232);
645 d = 9 + ceil_quot(reclen + 6 * (dn + 1), 34);
646 sector = (49 + (rec_on_trk - 1) * (10 + d)) / 8;
649 d = 7 + ceil_quot(reclen + 12, 32);
650 sector = (39 + (rec_on_trk - 1) * (8 + d)) / 7;
654 data->sector = sector;
655 data->count = no_rec;
657 case DASD_ECKD_CCW_WRITE_HOME_ADDRESS:
658 data->operation.orientation = 0x3;
659 data->operation.operation = 0x03;
661 case DASD_ECKD_CCW_READ_HOME_ADDRESS:
662 data->operation.orientation = 0x3;
663 data->operation.operation = 0x16;
665 case DASD_ECKD_CCW_WRITE_RECORD_ZERO:
666 data->operation.orientation = 0x1;
667 data->operation.operation = 0x03;
670 case DASD_ECKD_CCW_READ_RECORD_ZERO:
671 data->operation.orientation = 0x3;
672 data->operation.operation = 0x16;
675 case DASD_ECKD_CCW_WRITE:
676 case DASD_ECKD_CCW_WRITE_MT:
677 case DASD_ECKD_CCW_WRITE_KD:
678 case DASD_ECKD_CCW_WRITE_KD_MT:
679 data->auxiliary.last_bytes_used = 0x1;
680 data->length = reclen;
681 data->operation.operation = 0x01;
683 case DASD_ECKD_CCW_WRITE_CKD:
684 case DASD_ECKD_CCW_WRITE_CKD_MT:
685 data->auxiliary.last_bytes_used = 0x1;
686 data->length = reclen;
687 data->operation.operation = 0x03;
689 case DASD_ECKD_CCW_READ:
690 case DASD_ECKD_CCW_READ_MT:
691 case DASD_ECKD_CCW_READ_KD:
692 case DASD_ECKD_CCW_READ_KD_MT:
693 data->auxiliary.last_bytes_used = 0x1;
694 data->length = reclen;
695 data->operation.operation = 0x06;
697 case DASD_ECKD_CCW_READ_CKD:
698 case DASD_ECKD_CCW_READ_CKD_MT:
699 data->auxiliary.last_bytes_used = 0x1;
700 data->length = reclen;
701 data->operation.operation = 0x16;
703 case DASD_ECKD_CCW_READ_COUNT:
704 data->operation.operation = 0x06;
706 case DASD_ECKD_CCW_ERASE:
707 data->length = reclen;
708 data->auxiliary.last_bytes_used = 0x1;
709 data->operation.operation = 0x0b;
712 DBF_DEV_EVENT(DBF_ERR, device, "unknown locate record "
715 set_ch_t(&data->seek_addr,
716 trk / private->rdc_data.trk_per_cyl,
717 trk % private->rdc_data.trk_per_cyl);
718 data->search_arg.cyl = data->seek_addr.cyl;
719 data->search_arg.head = data->seek_addr.head;
720 data->search_arg.record = rec_on_trk;
724 * Returns 1 if the block is one of the special blocks that needs
725 * to get read/written with the KD variant of the command.
726 * That is DASD_ECKD_READ_KD_MT instead of DASD_ECKD_READ_MT and
727 * DASD_ECKD_WRITE_KD_MT instead of DASD_ECKD_WRITE_MT.
728 * Luckily the KD variants differ only by one bit (0x08) from the
729 * normal variant. So don't wonder about code like:
730 * if (dasd_eckd_cdl_special(blk_per_trk, recid))
731 * ccw->cmd_code |= 0x8;
734 dasd_eckd_cdl_special(int blk_per_trk, int recid)
738 if (recid < blk_per_trk)
740 if (recid < 2 * blk_per_trk)
746 * Returns the record size for the special blocks of the cdl format.
747 * Only returns something useful if dasd_eckd_cdl_special is true
751 dasd_eckd_cdl_reclen(int recid)
754 return sizes_trk0[recid];
757 /* create unique id from private structure. */
758 static void create_uid(struct dasd_eckd_private *private)
761 struct dasd_uid *uid;
764 memset(uid, 0, sizeof(struct dasd_uid));
765 memcpy(uid->vendor, private->ned->HDA_manufacturer,
766 sizeof(uid->vendor) - 1);
767 EBCASC(uid->vendor, sizeof(uid->vendor) - 1);
768 memcpy(uid->serial, private->ned->HDA_location,
769 sizeof(uid->serial) - 1);
770 EBCASC(uid->serial, sizeof(uid->serial) - 1);
771 uid->ssid = private->gneq->subsystemID;
772 uid->real_unit_addr = private->ned->unit_addr;
774 uid->type = private->sneq->sua_flags;
775 if (uid->type == UA_BASE_PAV_ALIAS)
776 uid->base_unit_addr = private->sneq->base_unit_addr;
778 uid->type = UA_BASE_DEVICE;
780 if (private->vdsneq) {
781 for (count = 0; count < 16; count++) {
782 sprintf(uid->vduit+2*count, "%02x",
783 private->vdsneq->uit[count]);
789 * Generate device unique id that specifies the physical device.
791 static int dasd_eckd_generate_uid(struct dasd_device *device)
793 struct dasd_eckd_private *private;
796 private = (struct dasd_eckd_private *) device->private;
799 if (!private->ned || !private->gneq)
801 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
803 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
807 static int dasd_eckd_get_uid(struct dasd_device *device, struct dasd_uid *uid)
809 struct dasd_eckd_private *private;
812 if (device->private) {
813 private = (struct dasd_eckd_private *)device->private;
814 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
816 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
823 * compare device UID with data of a given dasd_eckd_private structure
826 static int dasd_eckd_compare_path_uid(struct dasd_device *device,
827 struct dasd_eckd_private *private)
829 struct dasd_uid device_uid;
832 dasd_eckd_get_uid(device, &device_uid);
834 return memcmp(&device_uid, &private->uid, sizeof(struct dasd_uid));
837 static void dasd_eckd_fill_rcd_cqr(struct dasd_device *device,
838 struct dasd_ccw_req *cqr,
844 * buffer has to start with EBCDIC "V1.0" to show
845 * support for virtual device SNEQ
847 rcd_buffer[0] = 0xE5;
848 rcd_buffer[1] = 0xF1;
849 rcd_buffer[2] = 0x4B;
850 rcd_buffer[3] = 0xF0;
853 ccw->cmd_code = DASD_ECKD_CCW_RCD;
855 ccw->cda = (__u32)(addr_t)rcd_buffer;
856 ccw->count = DASD_ECKD_RCD_DATA_SIZE;
857 cqr->magic = DASD_ECKD_MAGIC;
859 cqr->startdev = device;
860 cqr->memdev = device;
862 cqr->expires = 10*HZ;
865 cqr->buildclk = get_tod_clock();
866 cqr->status = DASD_CQR_FILLED;
867 set_bit(DASD_CQR_VERIFY_PATH, &cqr->flags);
871 * Wakeup helper for read_conf
872 * if the cqr is not done and needs some error recovery
873 * the buffer has to be re-initialized with the EBCDIC "V1.0"
874 * to show support for virtual device SNEQ
876 static void read_conf_cb(struct dasd_ccw_req *cqr, void *data)
881 if (cqr->status != DASD_CQR_DONE) {
883 rcd_buffer = (__u8 *)((addr_t) ccw->cda);
884 memset(rcd_buffer, 0, sizeof(*rcd_buffer));
886 rcd_buffer[0] = 0xE5;
887 rcd_buffer[1] = 0xF1;
888 rcd_buffer[2] = 0x4B;
889 rcd_buffer[3] = 0xF0;
891 dasd_wakeup_cb(cqr, data);
894 static int dasd_eckd_read_conf_immediately(struct dasd_device *device,
895 struct dasd_ccw_req *cqr,
902 * sanity check: scan for RCD command in extended SenseID data
903 * some devices do not support RCD
905 ciw = ccw_device_get_ciw(device->cdev, CIW_TYPE_RCD);
906 if (!ciw || ciw->cmd != DASD_ECKD_CCW_RCD)
909 dasd_eckd_fill_rcd_cqr(device, cqr, rcd_buffer, lpm);
910 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
911 set_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags);
913 cqr->callback = read_conf_cb;
914 rc = dasd_sleep_on_immediatly(cqr);
918 static int dasd_eckd_read_conf_lpm(struct dasd_device *device,
920 int *rcd_buffer_size, __u8 lpm)
923 char *rcd_buf = NULL;
925 struct dasd_ccw_req *cqr;
928 * sanity check: scan for RCD command in extended SenseID data
929 * some devices do not support RCD
931 ciw = ccw_device_get_ciw(device->cdev, CIW_TYPE_RCD);
932 if (!ciw || ciw->cmd != DASD_ECKD_CCW_RCD) {
936 rcd_buf = kzalloc(DASD_ECKD_RCD_DATA_SIZE, GFP_KERNEL | GFP_DMA);
941 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* RCD */,
942 0, /* use rcd_buf as data ara */
945 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
946 "Could not allocate RCD request");
950 dasd_eckd_fill_rcd_cqr(device, cqr, rcd_buf, lpm);
951 cqr->callback = read_conf_cb;
952 ret = dasd_sleep_on(cqr);
954 * on success we update the user input parms
956 dasd_sfree_request(cqr, cqr->memdev);
960 *rcd_buffer_size = DASD_ECKD_RCD_DATA_SIZE;
961 *rcd_buffer = rcd_buf;
966 *rcd_buffer_size = 0;
970 static int dasd_eckd_identify_conf_parts(struct dasd_eckd_private *private)
973 struct dasd_sneq *sneq;
977 private->sneq = NULL;
978 private->vdsneq = NULL;
979 private->gneq = NULL;
980 count = private->conf_len / sizeof(struct dasd_sneq);
981 sneq = (struct dasd_sneq *)private->conf_data;
982 for (i = 0; i < count; ++i) {
983 if (sneq->flags.identifier == 1 && sneq->format == 1)
984 private->sneq = sneq;
985 else if (sneq->flags.identifier == 1 && sneq->format == 4)
986 private->vdsneq = (struct vd_sneq *)sneq;
987 else if (sneq->flags.identifier == 2)
988 private->gneq = (struct dasd_gneq *)sneq;
989 else if (sneq->flags.identifier == 3 && sneq->res1 == 1)
990 private->ned = (struct dasd_ned *)sneq;
993 if (!private->ned || !private->gneq) {
995 private->sneq = NULL;
996 private->vdsneq = NULL;
997 private->gneq = NULL;
1004 static unsigned char dasd_eckd_path_access(void *conf_data, int conf_len)
1006 struct dasd_gneq *gneq;
1007 int i, count, found;
1009 count = conf_len / sizeof(*gneq);
1010 gneq = (struct dasd_gneq *)conf_data;
1012 for (i = 0; i < count; ++i) {
1013 if (gneq->flags.identifier == 2) {
1020 return ((char *)gneq)[18] & 0x07;
1025 static int dasd_eckd_read_conf(struct dasd_device *device)
1028 int conf_len, conf_data_saved;
1031 struct dasd_eckd_private *private, path_private;
1032 struct dasd_path *path_data;
1033 struct dasd_uid *uid;
1034 char print_path_uid[60], print_device_uid[60];
1036 private = (struct dasd_eckd_private *) device->private;
1037 path_data = &device->path_data;
1038 opm = ccw_device_get_path_mask(device->cdev);
1039 conf_data_saved = 0;
1041 /* get configuration data per operational path */
1042 for (lpm = 0x80; lpm; lpm>>= 1) {
1045 rc = dasd_eckd_read_conf_lpm(device, &conf_data,
1047 if (rc && rc != -EOPNOTSUPP) { /* -EOPNOTSUPP is ok */
1048 DBF_EVENT_DEVID(DBF_WARNING, device->cdev,
1049 "Read configuration data returned "
1053 if (conf_data == NULL) {
1054 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "%s",
1055 "No configuration data "
1057 /* no further analysis possible */
1058 path_data->opm |= lpm;
1059 continue; /* no error */
1061 /* save first valid configuration data */
1062 if (!conf_data_saved) {
1063 kfree(private->conf_data);
1064 private->conf_data = conf_data;
1065 private->conf_len = conf_len;
1066 if (dasd_eckd_identify_conf_parts(private)) {
1067 private->conf_data = NULL;
1068 private->conf_len = 0;
1073 * build device UID that other path data
1074 * can be compared to it
1076 dasd_eckd_generate_uid(device);
1079 path_private.conf_data = conf_data;
1080 path_private.conf_len = DASD_ECKD_RCD_DATA_SIZE;
1081 if (dasd_eckd_identify_conf_parts(
1083 path_private.conf_data = NULL;
1084 path_private.conf_len = 0;
1089 if (dasd_eckd_compare_path_uid(
1090 device, &path_private)) {
1091 uid = &path_private.uid;
1092 if (strlen(uid->vduit) > 0)
1093 snprintf(print_path_uid,
1094 sizeof(print_path_uid),
1095 "%s.%s.%04x.%02x.%s",
1096 uid->vendor, uid->serial,
1097 uid->ssid, uid->real_unit_addr,
1100 snprintf(print_path_uid,
1101 sizeof(print_path_uid),
1103 uid->vendor, uid->serial,
1105 uid->real_unit_addr);
1106 uid = &private->uid;
1107 if (strlen(uid->vduit) > 0)
1108 snprintf(print_device_uid,
1109 sizeof(print_device_uid),
1110 "%s.%s.%04x.%02x.%s",
1111 uid->vendor, uid->serial,
1112 uid->ssid, uid->real_unit_addr,
1115 snprintf(print_device_uid,
1116 sizeof(print_device_uid),
1118 uid->vendor, uid->serial,
1120 uid->real_unit_addr);
1121 dev_err(&device->cdev->dev,
1122 "Not all channel paths lead to "
1123 "the same device, path %02X leads to "
1124 "device %s instead of %s\n", lpm,
1125 print_path_uid, print_device_uid);
1130 path_private.conf_data = NULL;
1131 path_private.conf_len = 0;
1133 switch (dasd_eckd_path_access(conf_data, conf_len)) {
1135 path_data->npm |= lpm;
1138 path_data->ppm |= lpm;
1141 path_data->opm |= lpm;
1143 if (conf_data != private->conf_data)
1150 static int verify_fcx_max_data(struct dasd_device *device, __u8 lpm)
1152 struct dasd_eckd_private *private;
1156 private = (struct dasd_eckd_private *) device->private;
1157 if (private->fcx_max_data) {
1158 mdc = ccw_device_get_mdc(device->cdev, lpm);
1160 dev_warn(&device->cdev->dev,
1161 "Detecting the maximum data size for zHPF "
1162 "requests failed (rc=%d) for a new path %x\n",
1166 fcx_max_data = mdc * FCX_MAX_DATA_FACTOR;
1167 if (fcx_max_data < private->fcx_max_data) {
1168 dev_warn(&device->cdev->dev,
1169 "The maximum data size for zHPF requests %u "
1170 "on a new path %x is below the active maximum "
1171 "%u\n", fcx_max_data, lpm,
1172 private->fcx_max_data);
1179 static int rebuild_device_uid(struct dasd_device *device,
1180 struct path_verification_work_data *data)
1182 struct dasd_eckd_private *private;
1183 struct dasd_path *path_data;
1188 private = (struct dasd_eckd_private *) device->private;
1189 path_data = &device->path_data;
1190 opm = device->path_data.opm;
1192 for (lpm = 0x80; lpm; lpm >>= 1) {
1195 memset(&data->rcd_buffer, 0, sizeof(data->rcd_buffer));
1196 memset(&data->cqr, 0, sizeof(data->cqr));
1197 data->cqr.cpaddr = &data->ccw;
1198 rc = dasd_eckd_read_conf_immediately(device, &data->cqr,
1203 if (rc == -EOPNOTSUPP) /* -EOPNOTSUPP is ok */
1205 DBF_EVENT_DEVID(DBF_WARNING, device->cdev,
1206 "Read configuration data "
1207 "returned error %d", rc);
1210 memcpy(private->conf_data, data->rcd_buffer,
1211 DASD_ECKD_RCD_DATA_SIZE);
1212 if (dasd_eckd_identify_conf_parts(private)) {
1214 } else /* first valid path is enough */
1219 rc = dasd_eckd_generate_uid(device);
1224 static void do_path_verification_work(struct work_struct *work)
1226 struct path_verification_work_data *data;
1227 struct dasd_device *device;
1228 struct dasd_eckd_private path_private;
1229 struct dasd_uid *uid;
1230 __u8 path_rcd_buf[DASD_ECKD_RCD_DATA_SIZE];
1231 __u8 lpm, opm, npm, ppm, epm;
1232 unsigned long flags;
1236 data = container_of(work, struct path_verification_work_data, worker);
1237 device = data->device;
1239 /* delay path verification until device was resumed */
1240 if (test_bit(DASD_FLAG_SUSPENDED, &device->flags)) {
1241 schedule_work(work);
1249 for (lpm = 0x80; lpm; lpm >>= 1) {
1250 if (!(lpm & data->tbvpm))
1252 memset(&data->rcd_buffer, 0, sizeof(data->rcd_buffer));
1253 memset(&data->cqr, 0, sizeof(data->cqr));
1254 data->cqr.cpaddr = &data->ccw;
1255 rc = dasd_eckd_read_conf_immediately(device, &data->cqr,
1259 switch (dasd_eckd_path_access(data->rcd_buffer,
1260 DASD_ECKD_RCD_DATA_SIZE)
1270 } else if (rc == -EOPNOTSUPP) {
1271 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "%s",
1272 "path verification: No configuration "
1275 } else if (rc == -EAGAIN) {
1276 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "%s",
1277 "path verification: device is stopped,"
1278 " try again later");
1281 dev_warn(&device->cdev->dev,
1282 "Reading device feature codes failed "
1283 "(rc=%d) for new path %x\n", rc, lpm);
1286 if (verify_fcx_max_data(device, lpm)) {
1294 * save conf_data for comparison after
1295 * rebuild_device_uid may have changed
1298 memcpy(&path_rcd_buf, data->rcd_buffer,
1299 DASD_ECKD_RCD_DATA_SIZE);
1300 path_private.conf_data = (void *) &path_rcd_buf;
1301 path_private.conf_len = DASD_ECKD_RCD_DATA_SIZE;
1302 if (dasd_eckd_identify_conf_parts(&path_private)) {
1303 path_private.conf_data = NULL;
1304 path_private.conf_len = 0;
1309 * compare path UID with device UID only if at least
1310 * one valid path is left
1311 * in other case the device UID may have changed and
1312 * the first working path UID will be used as device UID
1314 if (device->path_data.opm &&
1315 dasd_eckd_compare_path_uid(device, &path_private)) {
1317 * the comparison was not successful
1318 * rebuild the device UID with at least one
1319 * known path in case a z/VM hyperswap command
1320 * has changed the device
1322 * after this compare again
1324 * if either the rebuild or the recompare fails
1325 * the path can not be used
1327 if (rebuild_device_uid(device, data) ||
1328 dasd_eckd_compare_path_uid(
1329 device, &path_private)) {
1330 uid = &path_private.uid;
1331 if (strlen(uid->vduit) > 0)
1332 snprintf(print_uid, sizeof(print_uid),
1333 "%s.%s.%04x.%02x.%s",
1334 uid->vendor, uid->serial,
1335 uid->ssid, uid->real_unit_addr,
1338 snprintf(print_uid, sizeof(print_uid),
1340 uid->vendor, uid->serial,
1342 uid->real_unit_addr);
1343 dev_err(&device->cdev->dev,
1344 "The newly added channel path %02X "
1345 "will not be used because it leads "
1346 "to a different device %s\n",
1356 * There is a small chance that a path is lost again between
1357 * above path verification and the following modification of
1358 * the device opm mask. We could avoid that race here by using
1359 * yet another path mask, but we rather deal with this unlikely
1360 * situation in dasd_start_IO.
1362 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
1363 if (!device->path_data.opm && opm) {
1364 device->path_data.opm = opm;
1365 dasd_generic_path_operational(device);
1367 device->path_data.opm |= opm;
1368 device->path_data.npm |= npm;
1369 device->path_data.ppm |= ppm;
1370 device->path_data.tbvpm |= epm;
1371 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
1374 dasd_put_device(device);
1376 mutex_unlock(&dasd_path_verification_mutex);
1381 static int dasd_eckd_verify_path(struct dasd_device *device, __u8 lpm)
1383 struct path_verification_work_data *data;
1385 data = kmalloc(sizeof(*data), GFP_ATOMIC | GFP_DMA);
1387 if (mutex_trylock(&dasd_path_verification_mutex)) {
1388 data = path_verification_worker;
1393 memset(data, 0, sizeof(*data));
1396 INIT_WORK(&data->worker, do_path_verification_work);
1397 dasd_get_device(device);
1398 data->device = device;
1400 schedule_work(&data->worker);
1404 static int dasd_eckd_read_features(struct dasd_device *device)
1406 struct dasd_psf_prssd_data *prssdp;
1407 struct dasd_rssd_features *features;
1408 struct dasd_ccw_req *cqr;
1411 struct dasd_eckd_private *private;
1413 private = (struct dasd_eckd_private *) device->private;
1414 memset(&private->features, 0, sizeof(struct dasd_rssd_features));
1415 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */,
1416 (sizeof(struct dasd_psf_prssd_data) +
1417 sizeof(struct dasd_rssd_features)),
1420 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "%s", "Could not "
1421 "allocate initialization request");
1422 return PTR_ERR(cqr);
1424 cqr->startdev = device;
1425 cqr->memdev = device;
1428 cqr->expires = 10 * HZ;
1430 /* Prepare for Read Subsystem Data */
1431 prssdp = (struct dasd_psf_prssd_data *) cqr->data;
1432 memset(prssdp, 0, sizeof(struct dasd_psf_prssd_data));
1433 prssdp->order = PSF_ORDER_PRSSD;
1434 prssdp->suborder = 0x41; /* Read Feature Codes */
1435 /* all other bytes of prssdp must be zero */
1438 ccw->cmd_code = DASD_ECKD_CCW_PSF;
1439 ccw->count = sizeof(struct dasd_psf_prssd_data);
1440 ccw->flags |= CCW_FLAG_CC;
1441 ccw->cda = (__u32)(addr_t) prssdp;
1443 /* Read Subsystem Data - feature codes */
1444 features = (struct dasd_rssd_features *) (prssdp + 1);
1445 memset(features, 0, sizeof(struct dasd_rssd_features));
1448 ccw->cmd_code = DASD_ECKD_CCW_RSSD;
1449 ccw->count = sizeof(struct dasd_rssd_features);
1450 ccw->cda = (__u32)(addr_t) features;
1452 cqr->buildclk = get_tod_clock();
1453 cqr->status = DASD_CQR_FILLED;
1454 rc = dasd_sleep_on(cqr);
1456 prssdp = (struct dasd_psf_prssd_data *) cqr->data;
1457 features = (struct dasd_rssd_features *) (prssdp + 1);
1458 memcpy(&private->features, features,
1459 sizeof(struct dasd_rssd_features));
1461 dev_warn(&device->cdev->dev, "Reading device feature codes"
1462 " failed with rc=%d\n", rc);
1463 dasd_sfree_request(cqr, cqr->memdev);
1469 * Build CP for Perform Subsystem Function - SSC.
1471 static struct dasd_ccw_req *dasd_eckd_build_psf_ssc(struct dasd_device *device,
1474 struct dasd_ccw_req *cqr;
1475 struct dasd_psf_ssc_data *psf_ssc_data;
1478 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ ,
1479 sizeof(struct dasd_psf_ssc_data),
1483 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
1484 "Could not allocate PSF-SSC request");
1487 psf_ssc_data = (struct dasd_psf_ssc_data *)cqr->data;
1488 psf_ssc_data->order = PSF_ORDER_SSC;
1489 psf_ssc_data->suborder = 0xc0;
1491 psf_ssc_data->suborder |= 0x08;
1492 psf_ssc_data->reserved[0] = 0x88;
1495 ccw->cmd_code = DASD_ECKD_CCW_PSF;
1496 ccw->cda = (__u32)(addr_t)psf_ssc_data;
1499 cqr->startdev = device;
1500 cqr->memdev = device;
1503 cqr->expires = 10*HZ;
1504 cqr->buildclk = get_tod_clock();
1505 cqr->status = DASD_CQR_FILLED;
1510 * Perform Subsystem Function.
1511 * It is necessary to trigger CIO for channel revalidation since this
1512 * call might change behaviour of DASD devices.
1515 dasd_eckd_psf_ssc(struct dasd_device *device, int enable_pav,
1516 unsigned long flags)
1518 struct dasd_ccw_req *cqr;
1521 cqr = dasd_eckd_build_psf_ssc(device, enable_pav);
1523 return PTR_ERR(cqr);
1526 * set flags e.g. turn on failfast, to prevent blocking
1527 * the calling function should handle failed requests
1529 cqr->flags |= flags;
1531 rc = dasd_sleep_on(cqr);
1533 /* trigger CIO to reprobe devices */
1534 css_schedule_reprobe();
1535 else if (cqr->intrc == -EAGAIN)
1538 dasd_sfree_request(cqr, cqr->memdev);
1543 * Valide storage server of current device.
1545 static int dasd_eckd_validate_server(struct dasd_device *device,
1546 unsigned long flags)
1549 struct dasd_eckd_private *private;
1552 private = (struct dasd_eckd_private *) device->private;
1553 if (private->uid.type == UA_BASE_PAV_ALIAS ||
1554 private->uid.type == UA_HYPER_PAV_ALIAS)
1556 if (dasd_nopav || MACHINE_IS_VM)
1560 rc = dasd_eckd_psf_ssc(device, enable_pav, flags);
1562 /* may be requested feature is not available on server,
1563 * therefore just report error and go ahead */
1564 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "PSF-SSC for SSID %04x "
1565 "returned rc=%d", private->uid.ssid, rc);
1570 * worker to do a validate server in case of a lost pathgroup
1572 static void dasd_eckd_do_validate_server(struct work_struct *work)
1574 struct dasd_device *device = container_of(work, struct dasd_device,
1576 unsigned long flags = 0;
1578 set_bit(DASD_CQR_FLAGS_FAILFAST, &flags);
1579 if (dasd_eckd_validate_server(device, flags)
1581 /* schedule worker again if failed */
1582 schedule_work(&device->kick_validate);
1586 dasd_put_device(device);
1589 static void dasd_eckd_kick_validate_server(struct dasd_device *device)
1591 dasd_get_device(device);
1592 /* exit if device not online or in offline processing */
1593 if (test_bit(DASD_FLAG_OFFLINE, &device->flags) ||
1594 device->state < DASD_STATE_ONLINE) {
1595 dasd_put_device(device);
1598 /* queue call to do_validate_server to the kernel event daemon. */
1599 schedule_work(&device->kick_validate);
1602 static u32 get_fcx_max_data(struct dasd_device *device)
1604 #if defined(CONFIG_64BIT)
1606 int fcx_in_css, fcx_in_gneq, fcx_in_features;
1607 struct dasd_eckd_private *private;
1611 /* is transport mode supported? */
1612 private = (struct dasd_eckd_private *) device->private;
1613 fcx_in_css = css_general_characteristics.fcx;
1614 fcx_in_gneq = private->gneq->reserved2[7] & 0x04;
1615 fcx_in_features = private->features.feature[40] & 0x80;
1616 tpm = fcx_in_css && fcx_in_gneq && fcx_in_features;
1621 mdc = ccw_device_get_mdc(device->cdev, 0);
1623 dev_warn(&device->cdev->dev, "Detecting the maximum supported"
1624 " data size for zHPF requests failed\n");
1627 return mdc * FCX_MAX_DATA_FACTOR;
1634 * Check device characteristics.
1635 * If the device is accessible using ECKD discipline, the device is enabled.
1638 dasd_eckd_check_characteristics(struct dasd_device *device)
1640 struct dasd_eckd_private *private;
1641 struct dasd_block *block;
1642 struct dasd_uid temp_uid;
1645 unsigned long value;
1647 /* setup work queue for validate server*/
1648 INIT_WORK(&device->kick_validate, dasd_eckd_do_validate_server);
1650 if (!ccw_device_is_pathgroup(device->cdev)) {
1651 dev_warn(&device->cdev->dev,
1652 "A channel path group could not be established\n");
1655 if (!ccw_device_is_multipath(device->cdev)) {
1656 dev_info(&device->cdev->dev,
1657 "The DASD is not operating in multipath mode\n");
1659 private = (struct dasd_eckd_private *) device->private;
1661 private = kzalloc(sizeof(*private), GFP_KERNEL | GFP_DMA);
1663 dev_warn(&device->cdev->dev,
1664 "Allocating memory for private DASD data "
1668 device->private = (void *) private;
1670 memset(private, 0, sizeof(*private));
1672 /* Invalidate status of initial analysis. */
1673 private->init_cqr_status = -1;
1674 /* Set default cache operations. */
1675 private->attrib.operation = DASD_NORMAL_CACHE;
1676 private->attrib.nr_cyl = 0;
1678 /* Read Configuration Data */
1679 rc = dasd_eckd_read_conf(device);
1683 /* set default timeout */
1684 device->default_expires = DASD_EXPIRES;
1685 /* set default retry count */
1686 device->default_retries = DASD_RETRIES;
1688 if (private->gneq) {
1690 for (i = 0; i < private->gneq->timeout.value; i++)
1692 value = value * private->gneq->timeout.number;
1693 /* do not accept useless values */
1694 if (value != 0 && value <= DASD_EXPIRES_MAX)
1695 device->default_expires = value;
1698 dasd_eckd_get_uid(device, &temp_uid);
1699 if (temp_uid.type == UA_BASE_DEVICE) {
1700 block = dasd_alloc_block();
1701 if (IS_ERR(block)) {
1702 DBF_EVENT_DEVID(DBF_WARNING, device->cdev, "%s",
1703 "could not allocate dasd "
1705 rc = PTR_ERR(block);
1708 device->block = block;
1709 block->base = device;
1712 /* register lcu with alias handling, enable PAV */
1713 rc = dasd_alias_make_device_known_to_lcu(device);
1717 dasd_eckd_validate_server(device, 0);
1719 /* device may report different configuration data after LCU setup */
1720 rc = dasd_eckd_read_conf(device);
1724 /* Read Feature Codes */
1725 dasd_eckd_read_features(device);
1727 /* Read Device Characteristics */
1728 rc = dasd_generic_read_dev_chars(device, DASD_ECKD_MAGIC,
1729 &private->rdc_data, 64);
1731 DBF_EVENT_DEVID(DBF_WARNING, device->cdev,
1732 "Read device characteristic failed, rc=%d", rc);
1736 if ((device->features & DASD_FEATURE_USERAW) &&
1737 !(private->rdc_data.facilities.RT_in_LR)) {
1738 dev_err(&device->cdev->dev, "The storage server does not "
1739 "support raw-track access\n");
1744 /* find the valid cylinder size */
1745 if (private->rdc_data.no_cyl == LV_COMPAT_CYL &&
1746 private->rdc_data.long_no_cyl)
1747 private->real_cyl = private->rdc_data.long_no_cyl;
1749 private->real_cyl = private->rdc_data.no_cyl;
1751 private->fcx_max_data = get_fcx_max_data(device);
1753 readonly = dasd_device_is_ro(device);
1755 set_bit(DASD_FLAG_DEVICE_RO, &device->flags);
1757 dev_info(&device->cdev->dev, "New DASD %04X/%02X (CU %04X/%02X) "
1758 "with %d cylinders, %d heads, %d sectors%s\n",
1759 private->rdc_data.dev_type,
1760 private->rdc_data.dev_model,
1761 private->rdc_data.cu_type,
1762 private->rdc_data.cu_model.model,
1764 private->rdc_data.trk_per_cyl,
1765 private->rdc_data.sec_per_trk,
1766 readonly ? ", read-only device" : "");
1770 dasd_alias_disconnect_device_from_lcu(device);
1772 dasd_free_block(device->block);
1773 device->block = NULL;
1775 kfree(private->conf_data);
1776 kfree(device->private);
1777 device->private = NULL;
1781 static void dasd_eckd_uncheck_device(struct dasd_device *device)
1783 struct dasd_eckd_private *private;
1785 private = (struct dasd_eckd_private *) device->private;
1786 dasd_alias_disconnect_device_from_lcu(device);
1787 private->ned = NULL;
1788 private->sneq = NULL;
1789 private->vdsneq = NULL;
1790 private->gneq = NULL;
1791 private->conf_len = 0;
1792 kfree(private->conf_data);
1793 private->conf_data = NULL;
1796 static struct dasd_ccw_req *
1797 dasd_eckd_analysis_ccw(struct dasd_device *device)
1799 struct dasd_eckd_private *private;
1800 struct eckd_count *count_data;
1801 struct LO_eckd_data *LO_data;
1802 struct dasd_ccw_req *cqr;
1804 int cplength, datasize;
1807 private = (struct dasd_eckd_private *) device->private;
1810 datasize = sizeof(struct DE_eckd_data) + 2*sizeof(struct LO_eckd_data);
1811 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength, datasize, device);
1815 /* Define extent for the first 3 tracks. */
1816 define_extent(ccw++, cqr->data, 0, 2,
1817 DASD_ECKD_CCW_READ_COUNT, device);
1818 LO_data = cqr->data + sizeof(struct DE_eckd_data);
1819 /* Locate record for the first 4 records on track 0. */
1820 ccw[-1].flags |= CCW_FLAG_CC;
1821 locate_record(ccw++, LO_data++, 0, 0, 4,
1822 DASD_ECKD_CCW_READ_COUNT, device, 0);
1824 count_data = private->count_area;
1825 for (i = 0; i < 4; i++) {
1826 ccw[-1].flags |= CCW_FLAG_CC;
1827 ccw->cmd_code = DASD_ECKD_CCW_READ_COUNT;
1830 ccw->cda = (__u32)(addr_t) count_data;
1835 /* Locate record for the first record on track 2. */
1836 ccw[-1].flags |= CCW_FLAG_CC;
1837 locate_record(ccw++, LO_data++, 2, 0, 1,
1838 DASD_ECKD_CCW_READ_COUNT, device, 0);
1839 /* Read count ccw. */
1840 ccw[-1].flags |= CCW_FLAG_CC;
1841 ccw->cmd_code = DASD_ECKD_CCW_READ_COUNT;
1844 ccw->cda = (__u32)(addr_t) count_data;
1847 cqr->startdev = device;
1848 cqr->memdev = device;
1850 cqr->buildclk = get_tod_clock();
1851 cqr->status = DASD_CQR_FILLED;
1855 /* differentiate between 'no record found' and any other error */
1856 static int dasd_eckd_analysis_evaluation(struct dasd_ccw_req *init_cqr)
1859 if (init_cqr->status == DASD_CQR_DONE)
1861 else if (init_cqr->status == DASD_CQR_NEED_ERP ||
1862 init_cqr->status == DASD_CQR_FAILED) {
1863 sense = dasd_get_sense(&init_cqr->irb);
1864 if (sense && (sense[1] & SNS1_NO_REC_FOUND))
1865 return INIT_CQR_UNFORMATTED;
1867 return INIT_CQR_ERROR;
1869 return INIT_CQR_ERROR;
1873 * This is the callback function for the init_analysis cqr. It saves
1874 * the status of the initial analysis ccw before it frees it and kicks
1875 * the device to continue the startup sequence. This will call
1876 * dasd_eckd_do_analysis again (if the devices has not been marked
1877 * for deletion in the meantime).
1879 static void dasd_eckd_analysis_callback(struct dasd_ccw_req *init_cqr,
1882 struct dasd_eckd_private *private;
1883 struct dasd_device *device;
1885 device = init_cqr->startdev;
1886 private = (struct dasd_eckd_private *) device->private;
1887 private->init_cqr_status = dasd_eckd_analysis_evaluation(init_cqr);
1888 dasd_sfree_request(init_cqr, device);
1889 dasd_kick_device(device);
1892 static int dasd_eckd_start_analysis(struct dasd_block *block)
1894 struct dasd_ccw_req *init_cqr;
1896 init_cqr = dasd_eckd_analysis_ccw(block->base);
1897 if (IS_ERR(init_cqr))
1898 return PTR_ERR(init_cqr);
1899 init_cqr->callback = dasd_eckd_analysis_callback;
1900 init_cqr->callback_data = NULL;
1901 init_cqr->expires = 5*HZ;
1902 /* first try without ERP, so we can later handle unformatted
1903 * devices as special case
1905 clear_bit(DASD_CQR_FLAGS_USE_ERP, &init_cqr->flags);
1906 init_cqr->retries = 0;
1907 dasd_add_request_head(init_cqr);
1911 static int dasd_eckd_end_analysis(struct dasd_block *block)
1913 struct dasd_device *device;
1914 struct dasd_eckd_private *private;
1915 struct eckd_count *count_area;
1916 unsigned int sb, blk_per_trk;
1918 struct dasd_ccw_req *init_cqr;
1920 device = block->base;
1921 private = (struct dasd_eckd_private *) device->private;
1922 status = private->init_cqr_status;
1923 private->init_cqr_status = -1;
1924 if (status == INIT_CQR_ERROR) {
1925 /* try again, this time with full ERP */
1926 init_cqr = dasd_eckd_analysis_ccw(device);
1927 dasd_sleep_on(init_cqr);
1928 status = dasd_eckd_analysis_evaluation(init_cqr);
1929 dasd_sfree_request(init_cqr, device);
1932 if (device->features & DASD_FEATURE_USERAW) {
1933 block->bp_block = DASD_RAW_BLOCKSIZE;
1934 blk_per_trk = DASD_RAW_BLOCK_PER_TRACK;
1935 block->s2b_shift = 3;
1939 if (status == INIT_CQR_UNFORMATTED) {
1940 dev_warn(&device->cdev->dev, "The DASD is not formatted\n");
1941 return -EMEDIUMTYPE;
1942 } else if (status == INIT_CQR_ERROR) {
1943 dev_err(&device->cdev->dev,
1944 "Detecting the DASD disk layout failed because "
1945 "of an I/O error\n");
1949 private->uses_cdl = 1;
1950 /* Check Track 0 for Compatible Disk Layout */
1952 for (i = 0; i < 3; i++) {
1953 if (private->count_area[i].kl != 4 ||
1954 private->count_area[i].dl != dasd_eckd_cdl_reclen(i) - 4 ||
1955 private->count_area[i].cyl != 0 ||
1956 private->count_area[i].head != count_area_head[i] ||
1957 private->count_area[i].record != count_area_rec[i]) {
1958 private->uses_cdl = 0;
1963 count_area = &private->count_area[4];
1965 if (private->uses_cdl == 0) {
1966 for (i = 0; i < 5; i++) {
1967 if ((private->count_area[i].kl != 0) ||
1968 (private->count_area[i].dl !=
1969 private->count_area[0].dl) ||
1970 private->count_area[i].cyl != 0 ||
1971 private->count_area[i].head != count_area_head[i] ||
1972 private->count_area[i].record != count_area_rec[i])
1976 count_area = &private->count_area[0];
1978 if (private->count_area[3].record == 1)
1979 dev_warn(&device->cdev->dev,
1980 "Track 0 has no records following the VTOC\n");
1983 if (count_area != NULL && count_area->kl == 0) {
1984 /* we found notthing violating our disk layout */
1985 if (dasd_check_blocksize(count_area->dl) == 0)
1986 block->bp_block = count_area->dl;
1988 if (block->bp_block == 0) {
1989 dev_warn(&device->cdev->dev,
1990 "The disk layout of the DASD is not supported\n");
1991 return -EMEDIUMTYPE;
1993 block->s2b_shift = 0; /* bits to shift 512 to get a block */
1994 for (sb = 512; sb < block->bp_block; sb = sb << 1)
1997 blk_per_trk = recs_per_track(&private->rdc_data, 0, block->bp_block);
2000 block->blocks = (private->real_cyl *
2001 private->rdc_data.trk_per_cyl *
2004 dev_info(&device->cdev->dev,
2005 "DASD with %d KB/block, %d KB total size, %d KB/track, "
2006 "%s\n", (block->bp_block >> 10),
2007 ((private->real_cyl *
2008 private->rdc_data.trk_per_cyl *
2009 blk_per_trk * (block->bp_block >> 9)) >> 1),
2010 ((blk_per_trk * block->bp_block) >> 10),
2012 "compatible disk layout" : "linux disk layout");
2017 static int dasd_eckd_do_analysis(struct dasd_block *block)
2019 struct dasd_eckd_private *private;
2021 private = (struct dasd_eckd_private *) block->base->private;
2022 if (private->init_cqr_status < 0)
2023 return dasd_eckd_start_analysis(block);
2025 return dasd_eckd_end_analysis(block);
2028 static int dasd_eckd_basic_to_ready(struct dasd_device *device)
2030 return dasd_alias_add_device(device);
2033 static int dasd_eckd_online_to_ready(struct dasd_device *device)
2035 cancel_work_sync(&device->reload_device);
2036 cancel_work_sync(&device->kick_validate);
2040 static int dasd_eckd_ready_to_basic(struct dasd_device *device)
2042 return dasd_alias_remove_device(device);
2046 dasd_eckd_fill_geometry(struct dasd_block *block, struct hd_geometry *geo)
2048 struct dasd_eckd_private *private;
2050 private = (struct dasd_eckd_private *) block->base->private;
2051 if (dasd_check_blocksize(block->bp_block) == 0) {
2052 geo->sectors = recs_per_track(&private->rdc_data,
2053 0, block->bp_block);
2055 geo->cylinders = private->rdc_data.no_cyl;
2056 geo->heads = private->rdc_data.trk_per_cyl;
2060 static struct dasd_ccw_req *
2061 dasd_eckd_build_format(struct dasd_device *base,
2062 struct format_data_t *fdata)
2064 struct dasd_eckd_private *base_priv;
2065 struct dasd_eckd_private *start_priv;
2066 struct dasd_device *startdev;
2067 struct dasd_ccw_req *fcp;
2068 struct eckd_count *ect;
2069 struct ch_t address;
2073 int cplength, datasize;
2079 startdev = dasd_alias_get_start_dev(base);
2083 start_priv = (struct dasd_eckd_private *) startdev->private;
2084 base_priv = (struct dasd_eckd_private *) base->private;
2086 rpt = recs_per_track(&base_priv->rdc_data, 0, fdata->blksize);
2088 nr_tracks = fdata->stop_unit - fdata->start_unit + 1;
2091 * fdata->intensity is a bit string that tells us what to do:
2092 * Bit 0: write record zero
2093 * Bit 1: write home address, currently not supported
2094 * Bit 2: invalidate tracks
2095 * Bit 3: use OS/390 compatible disk layout (cdl)
2096 * Bit 4: do not allow storage subsystem to modify record zero
2097 * Only some bit combinations do make sense.
2099 if (fdata->intensity & 0x10) {
2101 intensity = fdata->intensity & ~0x10;
2104 intensity = fdata->intensity;
2107 switch (intensity) {
2108 case 0x00: /* Normal format */
2109 case 0x08: /* Normal format, use cdl. */
2110 cplength = 2 + (rpt*nr_tracks);
2111 datasize = sizeof(struct PFX_eckd_data) +
2112 sizeof(struct LO_eckd_data) +
2113 rpt * nr_tracks * sizeof(struct eckd_count);
2115 case 0x01: /* Write record zero and format track. */
2116 case 0x09: /* Write record zero and format track, use cdl. */
2117 cplength = 2 + rpt * nr_tracks;
2118 datasize = sizeof(struct PFX_eckd_data) +
2119 sizeof(struct LO_eckd_data) +
2120 sizeof(struct eckd_count) +
2121 rpt * nr_tracks * sizeof(struct eckd_count);
2123 case 0x04: /* Invalidate track. */
2124 case 0x0c: /* Invalidate track, use cdl. */
2126 datasize = sizeof(struct PFX_eckd_data) +
2127 sizeof(struct LO_eckd_data) +
2128 sizeof(struct eckd_count);
2131 dev_warn(&startdev->cdev->dev,
2132 "An I/O control call used incorrect flags 0x%x\n",
2134 return ERR_PTR(-EINVAL);
2136 /* Allocate the format ccw request. */
2137 fcp = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength,
2138 datasize, startdev);
2142 start_priv->count++;
2146 switch (intensity & ~0x08) {
2147 case 0x00: /* Normal format. */
2148 prefix(ccw++, (struct PFX_eckd_data *) data,
2149 fdata->start_unit, fdata->stop_unit,
2150 DASD_ECKD_CCW_WRITE_CKD, base, startdev);
2151 /* grant subsystem permission to format R0 */
2153 ((struct PFX_eckd_data *)data)
2154 ->define_extent.ga_extended |= 0x04;
2155 data += sizeof(struct PFX_eckd_data);
2156 ccw[-1].flags |= CCW_FLAG_CC;
2157 locate_record(ccw++, (struct LO_eckd_data *) data,
2158 fdata->start_unit, 0, rpt*nr_tracks,
2159 DASD_ECKD_CCW_WRITE_CKD, base,
2161 data += sizeof(struct LO_eckd_data);
2163 case 0x01: /* Write record zero + format track. */
2164 prefix(ccw++, (struct PFX_eckd_data *) data,
2165 fdata->start_unit, fdata->stop_unit,
2166 DASD_ECKD_CCW_WRITE_RECORD_ZERO,
2168 data += sizeof(struct PFX_eckd_data);
2169 ccw[-1].flags |= CCW_FLAG_CC;
2170 locate_record(ccw++, (struct LO_eckd_data *) data,
2171 fdata->start_unit, 0, rpt * nr_tracks + 1,
2172 DASD_ECKD_CCW_WRITE_RECORD_ZERO, base,
2173 base->block->bp_block);
2174 data += sizeof(struct LO_eckd_data);
2176 case 0x04: /* Invalidate track. */
2177 prefix(ccw++, (struct PFX_eckd_data *) data,
2178 fdata->start_unit, fdata->stop_unit,
2179 DASD_ECKD_CCW_WRITE_CKD, base, startdev);
2180 data += sizeof(struct PFX_eckd_data);
2181 ccw[-1].flags |= CCW_FLAG_CC;
2182 locate_record(ccw++, (struct LO_eckd_data *) data,
2183 fdata->start_unit, 0, 1,
2184 DASD_ECKD_CCW_WRITE_CKD, base, 8);
2185 data += sizeof(struct LO_eckd_data);
2189 for (j = 0; j < nr_tracks; j++) {
2190 /* calculate cylinder and head for the current track */
2192 (fdata->start_unit + j) /
2193 base_priv->rdc_data.trk_per_cyl,
2194 (fdata->start_unit + j) %
2195 base_priv->rdc_data.trk_per_cyl);
2196 if (intensity & 0x01) { /* write record zero */
2197 ect = (struct eckd_count *) data;
2198 data += sizeof(struct eckd_count);
2199 ect->cyl = address.cyl;
2200 ect->head = address.head;
2204 ccw[-1].flags |= CCW_FLAG_CC;
2205 ccw->cmd_code = DASD_ECKD_CCW_WRITE_RECORD_ZERO;
2206 ccw->flags = CCW_FLAG_SLI;
2208 ccw->cda = (__u32)(addr_t) ect;
2211 if ((intensity & ~0x08) & 0x04) { /* erase track */
2212 ect = (struct eckd_count *) data;
2213 data += sizeof(struct eckd_count);
2214 ect->cyl = address.cyl;
2215 ect->head = address.head;
2219 ccw[-1].flags |= CCW_FLAG_CC;
2220 ccw->cmd_code = DASD_ECKD_CCW_WRITE_CKD;
2221 ccw->flags = CCW_FLAG_SLI;
2223 ccw->cda = (__u32)(addr_t) ect;
2224 } else { /* write remaining records */
2225 for (i = 0; i < rpt; i++) {
2226 ect = (struct eckd_count *) data;
2227 data += sizeof(struct eckd_count);
2228 ect->cyl = address.cyl;
2229 ect->head = address.head;
2230 ect->record = i + 1;
2232 ect->dl = fdata->blksize;
2234 * Check for special tracks 0-1
2235 * when formatting CDL
2237 if ((intensity & 0x08) &&
2238 fdata->start_unit == 0) {
2241 ect->dl = sizes_trk0[i] - 4;
2244 if ((intensity & 0x08) &&
2245 fdata->start_unit == 1) {
2247 ect->dl = LABEL_SIZE - 44;
2249 ccw[-1].flags |= CCW_FLAG_CC;
2250 if (i != 0 || j == 0)
2252 DASD_ECKD_CCW_WRITE_CKD;
2255 DASD_ECKD_CCW_WRITE_CKD_MT;
2256 ccw->flags = CCW_FLAG_SLI;
2258 ccw->cda = (__u32)(addr_t) ect;
2264 fcp->startdev = startdev;
2265 fcp->memdev = startdev;
2267 fcp->expires = startdev->default_expires * HZ;
2268 fcp->buildclk = get_tod_clock();
2269 fcp->status = DASD_CQR_FILLED;
2275 dasd_eckd_format_device(struct dasd_device *base,
2276 struct format_data_t *fdata)
2278 struct dasd_ccw_req *cqr, *n;
2279 struct dasd_block *block;
2280 struct dasd_eckd_private *private;
2281 struct list_head format_queue;
2282 struct dasd_device *device;
2283 int old_stop, format_step;
2286 block = base->block;
2287 private = (struct dasd_eckd_private *) base->private;
2289 /* Sanity checks. */
2290 if (fdata->start_unit >=
2291 (private->real_cyl * private->rdc_data.trk_per_cyl)) {
2292 dev_warn(&base->cdev->dev,
2293 "Start track number %u used in formatting is too big\n",
2297 if (fdata->stop_unit >=
2298 (private->real_cyl * private->rdc_data.trk_per_cyl)) {
2299 dev_warn(&base->cdev->dev,
2300 "Stop track number %u used in formatting is too big\n",
2304 if (fdata->start_unit > fdata->stop_unit) {
2305 dev_warn(&base->cdev->dev,
2306 "Start track %u used in formatting exceeds end track\n",
2310 if (dasd_check_blocksize(fdata->blksize) != 0) {
2311 dev_warn(&base->cdev->dev,
2312 "The DASD cannot be formatted with block size %u\n",
2317 INIT_LIST_HEAD(&format_queue);
2318 old_stop = fdata->stop_unit;
2320 while (fdata->start_unit <= 1) {
2321 fdata->stop_unit = fdata->start_unit;
2322 cqr = dasd_eckd_build_format(base, fdata);
2323 list_add(&cqr->blocklist, &format_queue);
2325 fdata->stop_unit = old_stop;
2326 fdata->start_unit++;
2328 if (fdata->start_unit > fdata->stop_unit)
2333 format_step = 255 / recs_per_track(&private->rdc_data, 0,
2335 while (fdata->start_unit <= old_stop) {
2336 step = fdata->stop_unit - fdata->start_unit + 1;
2337 if (step > format_step)
2338 fdata->stop_unit = fdata->start_unit + format_step - 1;
2340 cqr = dasd_eckd_build_format(base, fdata);
2342 if (PTR_ERR(cqr) == -ENOMEM) {
2344 * not enough memory available
2345 * go to out and start requests
2346 * retry after first requests were finished
2348 fdata->stop_unit = old_stop;
2351 return PTR_ERR(cqr);
2353 list_add(&cqr->blocklist, &format_queue);
2355 fdata->start_unit = fdata->stop_unit + 1;
2356 fdata->stop_unit = old_stop;
2360 dasd_sleep_on_queue(&format_queue);
2362 list_for_each_entry_safe(cqr, n, &format_queue, blocklist) {
2363 device = cqr->startdev;
2364 private = (struct dasd_eckd_private *) device->private;
2365 if (cqr->status == DASD_CQR_FAILED)
2367 list_del_init(&cqr->blocklist);
2368 dasd_sfree_request(cqr, device);
2373 * in case of ENOMEM we need to retry after
2374 * first requests are finished
2376 if (fdata->start_unit <= fdata->stop_unit)
2382 static void dasd_eckd_handle_terminated_request(struct dasd_ccw_req *cqr)
2384 if (cqr->retries < 0) {
2385 cqr->status = DASD_CQR_FAILED;
2388 cqr->status = DASD_CQR_FILLED;
2389 if (cqr->block && (cqr->startdev != cqr->block->base)) {
2390 dasd_eckd_reset_ccw_to_base_io(cqr);
2391 cqr->startdev = cqr->block->base;
2392 cqr->lpm = cqr->block->base->path_data.opm;
2396 static dasd_erp_fn_t
2397 dasd_eckd_erp_action(struct dasd_ccw_req * cqr)
2399 struct dasd_device *device = (struct dasd_device *) cqr->startdev;
2400 struct ccw_device *cdev = device->cdev;
2402 switch (cdev->id.cu_type) {
2407 return dasd_3990_erp_action;
2411 return dasd_default_erp_action;
2415 static dasd_erp_fn_t
2416 dasd_eckd_erp_postaction(struct dasd_ccw_req * cqr)
2418 return dasd_default_erp_postaction;
2421 static void dasd_eckd_check_for_device_change(struct dasd_device *device,
2422 struct dasd_ccw_req *cqr,
2427 struct dasd_eckd_private *private;
2429 private = (struct dasd_eckd_private *) device->private;
2430 /* first of all check for state change pending interrupt */
2431 mask = DEV_STAT_ATTENTION | DEV_STAT_DEV_END | DEV_STAT_UNIT_EXCEP;
2432 if ((scsw_dstat(&irb->scsw) & mask) == mask) {
2434 * for alias only, not in offline processing
2435 * and only if not suspended
2437 if (!device->block && private->lcu &&
2438 device->state == DASD_STATE_ONLINE &&
2439 !test_bit(DASD_FLAG_OFFLINE, &device->flags) &&
2440 !test_bit(DASD_FLAG_SUSPENDED, &device->flags)) {
2442 * the state change could be caused by an alias
2443 * reassignment remove device from alias handling
2444 * to prevent new requests from being scheduled on
2445 * the wrong alias device
2447 dasd_alias_remove_device(device);
2449 /* schedule worker to reload device */
2450 dasd_reload_device(device);
2452 dasd_generic_handle_state_change(device);
2456 sense = dasd_get_sense(irb);
2460 /* summary unit check */
2461 if ((sense[27] & DASD_SENSE_BIT_0) && (sense[7] == 0x0D) &&
2462 (scsw_dstat(&irb->scsw) & DEV_STAT_UNIT_CHECK)) {
2463 dasd_alias_handle_summary_unit_check(device, irb);
2467 /* service information message SIM */
2468 if (!cqr && !(sense[27] & DASD_SENSE_BIT_0) &&
2469 ((sense[6] & DASD_SIM_SENSE) == DASD_SIM_SENSE)) {
2470 dasd_3990_erp_handle_sim(device, sense);
2474 /* loss of device reservation is handled via base devices only
2475 * as alias devices may be used with several bases
2477 if (device->block && (sense[27] & DASD_SENSE_BIT_0) &&
2478 (sense[7] == 0x3F) &&
2479 (scsw_dstat(&irb->scsw) & DEV_STAT_UNIT_CHECK) &&
2480 test_bit(DASD_FLAG_IS_RESERVED, &device->flags)) {
2481 if (device->features & DASD_FEATURE_FAILONSLCK)
2482 set_bit(DASD_FLAG_LOCK_STOLEN, &device->flags);
2483 clear_bit(DASD_FLAG_IS_RESERVED, &device->flags);
2484 dev_err(&device->cdev->dev,
2485 "The device reservation was lost\n");
2489 static struct dasd_ccw_req *dasd_eckd_build_cp_cmd_single(
2490 struct dasd_device *startdev,
2491 struct dasd_block *block,
2492 struct request *req,
2497 unsigned int first_offs,
2498 unsigned int last_offs,
2499 unsigned int blk_per_trk,
2500 unsigned int blksize)
2502 struct dasd_eckd_private *private;
2503 unsigned long *idaws;
2504 struct LO_eckd_data *LO_data;
2505 struct dasd_ccw_req *cqr;
2507 struct req_iterator iter;
2511 int count, cidaw, cplength, datasize;
2513 unsigned char cmd, rcmd;
2515 struct dasd_device *basedev;
2517 basedev = block->base;
2518 private = (struct dasd_eckd_private *) basedev->private;
2519 if (rq_data_dir(req) == READ)
2520 cmd = DASD_ECKD_CCW_READ_MT;
2521 else if (rq_data_dir(req) == WRITE)
2522 cmd = DASD_ECKD_CCW_WRITE_MT;
2524 return ERR_PTR(-EINVAL);
2526 /* Check struct bio and count the number of blocks for the request. */
2529 rq_for_each_segment(bv, req, iter) {
2530 if (bv->bv_len & (blksize - 1))
2531 /* Eckd can only do full blocks. */
2532 return ERR_PTR(-EINVAL);
2533 count += bv->bv_len >> (block->s2b_shift + 9);
2534 #if defined(CONFIG_64BIT)
2535 if (idal_is_needed (page_address(bv->bv_page), bv->bv_len))
2536 cidaw += bv->bv_len >> (block->s2b_shift + 9);
2540 if (count != last_rec - first_rec + 1)
2541 return ERR_PTR(-EINVAL);
2543 /* use the prefix command if available */
2544 use_prefix = private->features.feature[8] & 0x01;
2546 /* 1x prefix + number of blocks */
2547 cplength = 2 + count;
2548 /* 1x prefix + cidaws*sizeof(long) */
2549 datasize = sizeof(struct PFX_eckd_data) +
2550 sizeof(struct LO_eckd_data) +
2551 cidaw * sizeof(unsigned long);
2553 /* 1x define extent + 1x locate record + number of blocks */
2554 cplength = 2 + count;
2555 /* 1x define extent + 1x locate record + cidaws*sizeof(long) */
2556 datasize = sizeof(struct DE_eckd_data) +
2557 sizeof(struct LO_eckd_data) +
2558 cidaw * sizeof(unsigned long);
2560 /* Find out the number of additional locate record ccws for cdl. */
2561 if (private->uses_cdl && first_rec < 2*blk_per_trk) {
2562 if (last_rec >= 2*blk_per_trk)
2563 count = 2*blk_per_trk - first_rec;
2565 datasize += count*sizeof(struct LO_eckd_data);
2567 /* Allocate the ccw request. */
2568 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength, datasize,
2573 /* First ccw is define extent or prefix. */
2575 if (prefix(ccw++, cqr->data, first_trk,
2576 last_trk, cmd, basedev, startdev) == -EAGAIN) {
2577 /* Clock not in sync and XRC is enabled.
2580 dasd_sfree_request(cqr, startdev);
2581 return ERR_PTR(-EAGAIN);
2583 idaws = (unsigned long *) (cqr->data +
2584 sizeof(struct PFX_eckd_data));
2586 if (define_extent(ccw++, cqr->data, first_trk,
2587 last_trk, cmd, basedev) == -EAGAIN) {
2588 /* Clock not in sync and XRC is enabled.
2591 dasd_sfree_request(cqr, startdev);
2592 return ERR_PTR(-EAGAIN);
2594 idaws = (unsigned long *) (cqr->data +
2595 sizeof(struct DE_eckd_data));
2597 /* Build locate_record+read/write/ccws. */
2598 LO_data = (struct LO_eckd_data *) (idaws + cidaw);
2600 if (private->uses_cdl == 0 || recid > 2*blk_per_trk) {
2601 /* Only standard blocks so there is just one locate record. */
2602 ccw[-1].flags |= CCW_FLAG_CC;
2603 locate_record(ccw++, LO_data++, first_trk, first_offs + 1,
2604 last_rec - recid + 1, cmd, basedev, blksize);
2606 rq_for_each_segment(bv, req, iter) {
2607 dst = page_address(bv->bv_page) + bv->bv_offset;
2608 if (dasd_page_cache) {
2609 char *copy = kmem_cache_alloc(dasd_page_cache,
2610 GFP_DMA | __GFP_NOWARN);
2611 if (copy && rq_data_dir(req) == WRITE)
2612 memcpy(copy + bv->bv_offset, dst, bv->bv_len);
2614 dst = copy + bv->bv_offset;
2616 for (off = 0; off < bv->bv_len; off += blksize) {
2617 sector_t trkid = recid;
2618 unsigned int recoffs = sector_div(trkid, blk_per_trk);
2621 /* Locate record for cdl special block ? */
2622 if (private->uses_cdl && recid < 2*blk_per_trk) {
2623 if (dasd_eckd_cdl_special(blk_per_trk, recid)){
2625 count = dasd_eckd_cdl_reclen(recid);
2626 if (count < blksize &&
2627 rq_data_dir(req) == READ)
2628 memset(dst + count, 0xe5,
2631 ccw[-1].flags |= CCW_FLAG_CC;
2632 locate_record(ccw++, LO_data++,
2634 1, rcmd, basedev, count);
2636 /* Locate record for standard blocks ? */
2637 if (private->uses_cdl && recid == 2*blk_per_trk) {
2638 ccw[-1].flags |= CCW_FLAG_CC;
2639 locate_record(ccw++, LO_data++,
2641 last_rec - recid + 1,
2642 cmd, basedev, count);
2644 /* Read/write ccw. */
2645 ccw[-1].flags |= CCW_FLAG_CC;
2646 ccw->cmd_code = rcmd;
2648 if (idal_is_needed(dst, blksize)) {
2649 ccw->cda = (__u32)(addr_t) idaws;
2650 ccw->flags = CCW_FLAG_IDA;
2651 idaws = idal_create_words(idaws, dst, blksize);
2653 ccw->cda = (__u32)(addr_t) dst;
2661 if (blk_noretry_request(req) ||
2662 block->base->features & DASD_FEATURE_FAILFAST)
2663 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
2664 cqr->startdev = startdev;
2665 cqr->memdev = startdev;
2667 cqr->expires = startdev->default_expires * HZ; /* default 5 minutes */
2668 cqr->lpm = startdev->path_data.ppm;
2669 cqr->retries = startdev->default_retries;
2670 cqr->buildclk = get_tod_clock();
2671 cqr->status = DASD_CQR_FILLED;
2675 static struct dasd_ccw_req *dasd_eckd_build_cp_cmd_track(
2676 struct dasd_device *startdev,
2677 struct dasd_block *block,
2678 struct request *req,
2683 unsigned int first_offs,
2684 unsigned int last_offs,
2685 unsigned int blk_per_trk,
2686 unsigned int blksize)
2688 unsigned long *idaws;
2689 struct dasd_ccw_req *cqr;
2691 struct req_iterator iter;
2693 char *dst, *idaw_dst;
2694 unsigned int cidaw, cplength, datasize;
2698 struct dasd_device *basedev;
2699 unsigned int trkcount, count, count_to_trk_end;
2700 unsigned int idaw_len, seg_len, part_len, len_to_track_end;
2701 unsigned char new_track, end_idaw;
2703 unsigned int recoffs;
2705 basedev = block->base;
2706 if (rq_data_dir(req) == READ)
2707 cmd = DASD_ECKD_CCW_READ_TRACK_DATA;
2708 else if (rq_data_dir(req) == WRITE)
2709 cmd = DASD_ECKD_CCW_WRITE_TRACK_DATA;
2711 return ERR_PTR(-EINVAL);
2713 /* Track based I/O needs IDAWs for each page, and not just for
2714 * 64 bit addresses. We need additional idals for pages
2715 * that get filled from two tracks, so we use the number
2716 * of records as upper limit.
2718 cidaw = last_rec - first_rec + 1;
2719 trkcount = last_trk - first_trk + 1;
2721 /* 1x prefix + one read/write ccw per track */
2722 cplength = 1 + trkcount;
2724 /* on 31-bit we need space for two 32 bit addresses per page
2725 * on 64-bit one 64 bit address
2727 datasize = sizeof(struct PFX_eckd_data) +
2728 cidaw * sizeof(unsigned long long);
2730 /* Allocate the ccw request. */
2731 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength, datasize,
2736 /* transfer length factor: how many bytes to read from the last track */
2737 if (first_trk == last_trk)
2738 tlf = last_offs - first_offs + 1;
2740 tlf = last_offs + 1;
2743 if (prefix_LRE(ccw++, cqr->data, first_trk,
2744 last_trk, cmd, basedev, startdev,
2745 1 /* format */, first_offs + 1,
2748 /* Clock not in sync and XRC is enabled.
2751 dasd_sfree_request(cqr, startdev);
2752 return ERR_PTR(-EAGAIN);
2756 * The translation of request into ccw programs must meet the
2757 * following conditions:
2758 * - all idaws but the first and the last must address full pages
2759 * (or 2K blocks on 31-bit)
2760 * - the scope of a ccw and it's idal ends with the track boundaries
2762 idaws = (unsigned long *) (cqr->data + sizeof(struct PFX_eckd_data));
2766 len_to_track_end = 0;
2769 rq_for_each_segment(bv, req, iter) {
2770 dst = page_address(bv->bv_page) + bv->bv_offset;
2771 seg_len = bv->bv_len;
2775 recoffs = sector_div(trkid, blk_per_trk);
2776 count_to_trk_end = blk_per_trk - recoffs;
2777 count = min((last_rec - recid + 1),
2778 (sector_t)count_to_trk_end);
2779 len_to_track_end = count * blksize;
2780 ccw[-1].flags |= CCW_FLAG_CC;
2781 ccw->cmd_code = cmd;
2782 ccw->count = len_to_track_end;
2783 ccw->cda = (__u32)(addr_t)idaws;
2784 ccw->flags = CCW_FLAG_IDA;
2788 /* first idaw for a ccw may start anywhere */
2792 /* If we start a new idaw, we must make sure that it
2793 * starts on an IDA_BLOCK_SIZE boundary.
2794 * If we continue an idaw, we must make sure that the
2795 * current segment begins where the so far accumulated
2799 if (__pa(dst) & (IDA_BLOCK_SIZE-1)) {
2800 dasd_sfree_request(cqr, startdev);
2801 return ERR_PTR(-ERANGE);
2805 if ((idaw_dst + idaw_len) != dst) {
2806 dasd_sfree_request(cqr, startdev);
2807 return ERR_PTR(-ERANGE);
2809 part_len = min(seg_len, len_to_track_end);
2810 seg_len -= part_len;
2812 idaw_len += part_len;
2813 len_to_track_end -= part_len;
2814 /* collected memory area ends on an IDA_BLOCK border,
2816 * idal_create_words will handle cases where idaw_len
2817 * is larger then IDA_BLOCK_SIZE
2819 if (!(__pa(idaw_dst + idaw_len) & (IDA_BLOCK_SIZE-1)))
2821 /* We also need to end the idaw at track end */
2822 if (!len_to_track_end) {
2827 idaws = idal_create_words(idaws, idaw_dst,
2836 if (blk_noretry_request(req) ||
2837 block->base->features & DASD_FEATURE_FAILFAST)
2838 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
2839 cqr->startdev = startdev;
2840 cqr->memdev = startdev;
2842 cqr->expires = startdev->default_expires * HZ; /* default 5 minutes */
2843 cqr->lpm = startdev->path_data.ppm;
2844 cqr->retries = startdev->default_retries;
2845 cqr->buildclk = get_tod_clock();
2846 cqr->status = DASD_CQR_FILLED;
2850 static int prepare_itcw(struct itcw *itcw,
2851 unsigned int trk, unsigned int totrk, int cmd,
2852 struct dasd_device *basedev,
2853 struct dasd_device *startdev,
2854 unsigned int rec_on_trk, int count,
2855 unsigned int blksize,
2856 unsigned int total_data_size,
2858 unsigned int blk_per_trk)
2860 struct PFX_eckd_data pfxdata;
2861 struct dasd_eckd_private *basepriv, *startpriv;
2862 struct DE_eckd_data *dedata;
2863 struct LRE_eckd_data *lredata;
2867 u16 heads, beghead, endhead;
2875 /* setup prefix data */
2876 basepriv = (struct dasd_eckd_private *) basedev->private;
2877 startpriv = (struct dasd_eckd_private *) startdev->private;
2878 dedata = &pfxdata.define_extent;
2879 lredata = &pfxdata.locate_record;
2881 memset(&pfxdata, 0, sizeof(pfxdata));
2882 pfxdata.format = 1; /* PFX with LRE */
2883 pfxdata.base_address = basepriv->ned->unit_addr;
2884 pfxdata.base_lss = basepriv->ned->ID;
2885 pfxdata.validity.define_extent = 1;
2887 /* private uid is kept up to date, conf_data may be outdated */
2888 if (startpriv->uid.type != UA_BASE_DEVICE) {
2889 pfxdata.validity.verify_base = 1;
2890 if (startpriv->uid.type == UA_HYPER_PAV_ALIAS)
2891 pfxdata.validity.hyper_pav = 1;
2895 case DASD_ECKD_CCW_READ_TRACK_DATA:
2896 dedata->mask.perm = 0x1;
2897 dedata->attributes.operation = basepriv->attrib.operation;
2898 dedata->blk_size = blksize;
2899 dedata->ga_extended |= 0x42;
2900 lredata->operation.orientation = 0x0;
2901 lredata->operation.operation = 0x0C;
2902 lredata->auxiliary.check_bytes = 0x01;
2903 pfx_cmd = DASD_ECKD_CCW_PFX_READ;
2905 case DASD_ECKD_CCW_WRITE_TRACK_DATA:
2906 dedata->mask.perm = 0x02;
2907 dedata->attributes.operation = basepriv->attrib.operation;
2908 dedata->blk_size = blksize;
2909 rc = check_XRC_on_prefix(&pfxdata, basedev);
2910 dedata->ga_extended |= 0x42;
2911 lredata->operation.orientation = 0x0;
2912 lredata->operation.operation = 0x3F;
2913 lredata->extended_operation = 0x23;
2914 lredata->auxiliary.check_bytes = 0x2;
2915 pfx_cmd = DASD_ECKD_CCW_PFX;
2918 DBF_DEV_EVENT(DBF_ERR, basedev,
2919 "prepare itcw, unknown opcode 0x%x", cmd);
2926 dedata->attributes.mode = 0x3; /* ECKD */
2928 heads = basepriv->rdc_data.trk_per_cyl;
2929 begcyl = trk / heads;
2930 beghead = trk % heads;
2931 endcyl = totrk / heads;
2932 endhead = totrk % heads;
2934 /* check for sequential prestage - enhance cylinder range */
2935 if (dedata->attributes.operation == DASD_SEQ_PRESTAGE ||
2936 dedata->attributes.operation == DASD_SEQ_ACCESS) {
2938 if (endcyl + basepriv->attrib.nr_cyl < basepriv->real_cyl)
2939 endcyl += basepriv->attrib.nr_cyl;
2941 endcyl = (basepriv->real_cyl - 1);
2944 set_ch_t(&dedata->beg_ext, begcyl, beghead);
2945 set_ch_t(&dedata->end_ext, endcyl, endhead);
2947 dedata->ep_format = 0x20; /* records per track is valid */
2948 dedata->ep_rec_per_track = blk_per_trk;
2951 switch (basepriv->rdc_data.dev_type) {
2953 dn = ceil_quot(blksize + 6, 232);
2954 d = 9 + ceil_quot(blksize + 6 * (dn + 1), 34);
2955 sector = (49 + (rec_on_trk - 1) * (10 + d)) / 8;
2958 d = 7 + ceil_quot(blksize + 12, 32);
2959 sector = (39 + (rec_on_trk - 1) * (8 + d)) / 7;
2964 lredata->auxiliary.length_valid = 1;
2965 lredata->auxiliary.length_scope = 1;
2966 lredata->auxiliary.imbedded_ccw_valid = 1;
2967 lredata->length = tlf;
2968 lredata->imbedded_ccw = cmd;
2969 lredata->count = count;
2970 lredata->sector = sector;
2971 set_ch_t(&lredata->seek_addr, begcyl, beghead);
2972 lredata->search_arg.cyl = lredata->seek_addr.cyl;
2973 lredata->search_arg.head = lredata->seek_addr.head;
2974 lredata->search_arg.record = rec_on_trk;
2976 dcw = itcw_add_dcw(itcw, pfx_cmd, 0,
2977 &pfxdata, sizeof(pfxdata), total_data_size);
2978 return PTR_RET(dcw);
2981 static struct dasd_ccw_req *dasd_eckd_build_cp_tpm_track(
2982 struct dasd_device *startdev,
2983 struct dasd_block *block,
2984 struct request *req,
2989 unsigned int first_offs,
2990 unsigned int last_offs,
2991 unsigned int blk_per_trk,
2992 unsigned int blksize)
2994 struct dasd_ccw_req *cqr;
2995 struct req_iterator iter;
2998 unsigned int trkcount, ctidaw;
3000 struct dasd_device *basedev;
3003 struct tidaw *last_tidaw = NULL;
3007 unsigned int seg_len, part_len, len_to_track_end;
3008 unsigned char new_track;
3009 sector_t recid, trkid;
3011 unsigned int count, count_to_trk_end;
3014 basedev = block->base;
3015 if (rq_data_dir(req) == READ) {
3016 cmd = DASD_ECKD_CCW_READ_TRACK_DATA;
3017 itcw_op = ITCW_OP_READ;
3018 } else if (rq_data_dir(req) == WRITE) {
3019 cmd = DASD_ECKD_CCW_WRITE_TRACK_DATA;
3020 itcw_op = ITCW_OP_WRITE;
3022 return ERR_PTR(-EINVAL);
3024 /* trackbased I/O needs address all memory via TIDAWs,
3025 * not just for 64 bit addresses. This allows us to map
3026 * each segment directly to one tidaw.
3027 * In the case of write requests, additional tidaws may
3028 * be needed when a segment crosses a track boundary.
3030 trkcount = last_trk - first_trk + 1;
3032 rq_for_each_segment(bv, req, iter) {
3035 if (rq_data_dir(req) == WRITE)
3036 ctidaw += (last_trk - first_trk);
3038 /* Allocate the ccw request. */
3039 itcw_size = itcw_calc_size(0, ctidaw, 0);
3040 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 0, itcw_size, startdev);
3044 /* transfer length factor: how many bytes to read from the last track */
3045 if (first_trk == last_trk)
3046 tlf = last_offs - first_offs + 1;
3048 tlf = last_offs + 1;
3051 itcw = itcw_init(cqr->data, itcw_size, itcw_op, 0, ctidaw, 0);
3056 cqr->cpaddr = itcw_get_tcw(itcw);
3057 if (prepare_itcw(itcw, first_trk, last_trk,
3058 cmd, basedev, startdev,
3061 (last_rec - first_rec + 1) * blksize,
3062 tlf, blk_per_trk) == -EAGAIN) {
3063 /* Clock not in sync and XRC is enabled.
3069 len_to_track_end = 0;
3071 * A tidaw can address 4k of memory, but must not cross page boundaries
3072 * We can let the block layer handle this by setting
3073 * blk_queue_segment_boundary to page boundaries and
3074 * blk_max_segment_size to page size when setting up the request queue.
3075 * For write requests, a TIDAW must not cross track boundaries, because
3076 * we have to set the CBC flag on the last tidaw for each track.
3078 if (rq_data_dir(req) == WRITE) {
3081 rq_for_each_segment(bv, req, iter) {
3082 dst = page_address(bv->bv_page) + bv->bv_offset;
3083 seg_len = bv->bv_len;
3087 offs = sector_div(trkid, blk_per_trk);
3088 count_to_trk_end = blk_per_trk - offs;
3089 count = min((last_rec - recid + 1),
3090 (sector_t)count_to_trk_end);
3091 len_to_track_end = count * blksize;
3095 part_len = min(seg_len, len_to_track_end);
3096 seg_len -= part_len;
3097 len_to_track_end -= part_len;
3098 /* We need to end the tidaw at track end */
3099 if (!len_to_track_end) {
3101 tidaw_flags = TIDAW_FLAGS_INSERT_CBC;
3104 last_tidaw = itcw_add_tidaw(itcw, tidaw_flags,
3106 if (IS_ERR(last_tidaw)) {
3114 rq_for_each_segment(bv, req, iter) {
3115 dst = page_address(bv->bv_page) + bv->bv_offset;
3116 last_tidaw = itcw_add_tidaw(itcw, 0x00,
3118 if (IS_ERR(last_tidaw)) {
3124 last_tidaw->flags |= TIDAW_FLAGS_LAST;
3125 last_tidaw->flags &= ~TIDAW_FLAGS_INSERT_CBC;
3126 itcw_finalize(itcw);
3128 if (blk_noretry_request(req) ||
3129 block->base->features & DASD_FEATURE_FAILFAST)
3130 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
3132 cqr->startdev = startdev;
3133 cqr->memdev = startdev;
3135 cqr->expires = startdev->default_expires * HZ; /* default 5 minutes */
3136 cqr->lpm = startdev->path_data.ppm;
3137 cqr->retries = startdev->default_retries;
3138 cqr->buildclk = get_tod_clock();
3139 cqr->status = DASD_CQR_FILLED;
3142 dasd_sfree_request(cqr, startdev);
3143 return ERR_PTR(ret);
3146 static struct dasd_ccw_req *dasd_eckd_build_cp(struct dasd_device *startdev,
3147 struct dasd_block *block,
3148 struct request *req)
3153 struct dasd_eckd_private *private;
3154 struct dasd_device *basedev;
3155 sector_t first_rec, last_rec;
3156 sector_t first_trk, last_trk;
3157 unsigned int first_offs, last_offs;
3158 unsigned int blk_per_trk, blksize;
3160 unsigned int data_size;
3161 struct dasd_ccw_req *cqr;
3163 basedev = block->base;
3164 private = (struct dasd_eckd_private *) basedev->private;
3166 /* Calculate number of blocks/records per track. */
3167 blksize = block->bp_block;
3168 blk_per_trk = recs_per_track(&private->rdc_data, 0, blksize);
3169 if (blk_per_trk == 0)
3170 return ERR_PTR(-EINVAL);
3171 /* Calculate record id of first and last block. */
3172 first_rec = first_trk = blk_rq_pos(req) >> block->s2b_shift;
3173 first_offs = sector_div(first_trk, blk_per_trk);
3174 last_rec = last_trk =
3175 (blk_rq_pos(req) + blk_rq_sectors(req) - 1) >> block->s2b_shift;
3176 last_offs = sector_div(last_trk, blk_per_trk);
3177 cdlspecial = (private->uses_cdl && first_rec < 2*blk_per_trk);
3179 fcx_multitrack = private->features.feature[40] & 0x20;
3180 data_size = blk_rq_bytes(req);
3181 /* tpm write request add CBC data on each track boundary */
3182 if (rq_data_dir(req) == WRITE)
3183 data_size += (last_trk - first_trk) * 4;
3185 /* is read track data and write track data in command mode supported? */
3186 cmdrtd = private->features.feature[9] & 0x20;
3187 cmdwtd = private->features.feature[12] & 0x40;
3188 use_prefix = private->features.feature[8] & 0x01;
3191 if (cdlspecial || dasd_page_cache) {
3192 /* do nothing, just fall through to the cmd mode single case */
3193 } else if ((data_size <= private->fcx_max_data)
3194 && (fcx_multitrack || (first_trk == last_trk))) {
3195 cqr = dasd_eckd_build_cp_tpm_track(startdev, block, req,
3196 first_rec, last_rec,
3197 first_trk, last_trk,
3198 first_offs, last_offs,
3199 blk_per_trk, blksize);
3200 if (IS_ERR(cqr) && (PTR_ERR(cqr) != -EAGAIN) &&
3201 (PTR_ERR(cqr) != -ENOMEM))
3203 } else if (use_prefix &&
3204 (((rq_data_dir(req) == READ) && cmdrtd) ||
3205 ((rq_data_dir(req) == WRITE) && cmdwtd))) {
3206 cqr = dasd_eckd_build_cp_cmd_track(startdev, block, req,
3207 first_rec, last_rec,
3208 first_trk, last_trk,
3209 first_offs, last_offs,
3210 blk_per_trk, blksize);
3211 if (IS_ERR(cqr) && (PTR_ERR(cqr) != -EAGAIN) &&
3212 (PTR_ERR(cqr) != -ENOMEM))
3216 cqr = dasd_eckd_build_cp_cmd_single(startdev, block, req,
3217 first_rec, last_rec,
3218 first_trk, last_trk,
3219 first_offs, last_offs,
3220 blk_per_trk, blksize);
3224 static struct dasd_ccw_req *dasd_raw_build_cp(struct dasd_device *startdev,
3225 struct dasd_block *block,
3226 struct request *req)
3228 unsigned long *idaws;
3229 struct dasd_device *basedev;
3230 struct dasd_ccw_req *cqr;
3232 struct req_iterator iter;
3236 unsigned int trkcount;
3237 unsigned int seg_len, len_to_track_end;
3238 unsigned int first_offs;
3239 unsigned int cidaw, cplength, datasize;
3240 sector_t first_trk, last_trk;
3241 unsigned int pfx_datasize;
3244 * raw track access needs to be mutiple of 64k and on 64k boundary
3246 if ((blk_rq_pos(req) % DASD_RAW_SECTORS_PER_TRACK) != 0) {
3247 cqr = ERR_PTR(-EINVAL);
3250 if (((blk_rq_pos(req) + blk_rq_sectors(req)) %
3251 DASD_RAW_SECTORS_PER_TRACK) != 0) {
3252 cqr = ERR_PTR(-EINVAL);
3256 first_trk = blk_rq_pos(req) / DASD_RAW_SECTORS_PER_TRACK;
3257 last_trk = (blk_rq_pos(req) + blk_rq_sectors(req) - 1) /
3258 DASD_RAW_SECTORS_PER_TRACK;
3259 trkcount = last_trk - first_trk + 1;
3261 basedev = block->base;
3263 if (rq_data_dir(req) == READ)
3264 cmd = DASD_ECKD_CCW_READ_TRACK;
3265 else if (rq_data_dir(req) == WRITE)
3266 cmd = DASD_ECKD_CCW_WRITE_FULL_TRACK;
3268 cqr = ERR_PTR(-EINVAL);
3273 * Raw track based I/O needs IDAWs for each page,
3274 * and not just for 64 bit addresses.
3276 cidaw = trkcount * DASD_RAW_BLOCK_PER_TRACK;
3278 /* 1x prefix + one read/write ccw per track */
3279 cplength = 1 + trkcount;
3282 * struct PFX_eckd_data has up to 2 byte as extended parameter
3283 * this is needed for write full track and has to be mentioned
3285 * add 8 instead of 2 to keep 8 byte boundary
3287 pfx_datasize = sizeof(struct PFX_eckd_data) + 8;
3289 datasize = pfx_datasize + cidaw * sizeof(unsigned long long);
3291 /* Allocate the ccw request. */
3292 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, cplength,
3293 datasize, startdev);
3298 if (prefix_LRE(ccw++, cqr->data, first_trk, last_trk, cmd,
3299 basedev, startdev, 1 /* format */, first_offs + 1,
3300 trkcount, 0, 0) == -EAGAIN) {
3301 /* Clock not in sync and XRC is enabled.
3304 dasd_sfree_request(cqr, startdev);
3305 cqr = ERR_PTR(-EAGAIN);
3309 idaws = (unsigned long *)(cqr->data + pfx_datasize);
3311 len_to_track_end = 0;
3313 rq_for_each_segment(bv, req, iter) {
3314 dst = page_address(bv->bv_page) + bv->bv_offset;
3315 seg_len = bv->bv_len;
3316 if (!len_to_track_end) {
3317 ccw[-1].flags |= CCW_FLAG_CC;
3318 ccw->cmd_code = cmd;
3319 /* maximum 3390 track size */
3321 /* 64k map to one track */
3322 len_to_track_end = 65536;
3323 ccw->cda = (__u32)(addr_t)idaws;
3324 ccw->flags |= CCW_FLAG_IDA;
3325 ccw->flags |= CCW_FLAG_SLI;
3328 len_to_track_end -= seg_len;
3329 idaws = idal_create_words(idaws, dst, seg_len);
3332 if (blk_noretry_request(req) ||
3333 block->base->features & DASD_FEATURE_FAILFAST)
3334 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
3335 cqr->startdev = startdev;
3336 cqr->memdev = startdev;
3338 cqr->expires = startdev->default_expires * HZ;
3339 cqr->lpm = startdev->path_data.ppm;
3340 cqr->retries = startdev->default_retries;
3341 cqr->buildclk = get_tod_clock();
3342 cqr->status = DASD_CQR_FILLED;
3344 if (IS_ERR(cqr) && PTR_ERR(cqr) != -EAGAIN)
3352 dasd_eckd_free_cp(struct dasd_ccw_req *cqr, struct request *req)
3354 struct dasd_eckd_private *private;
3356 struct req_iterator iter;
3359 unsigned int blksize, blk_per_trk, off;
3363 if (!dasd_page_cache)
3365 private = (struct dasd_eckd_private *) cqr->block->base->private;
3366 blksize = cqr->block->bp_block;
3367 blk_per_trk = recs_per_track(&private->rdc_data, 0, blksize);
3368 recid = blk_rq_pos(req) >> cqr->block->s2b_shift;
3370 /* Skip over define extent & locate record. */
3372 if (private->uses_cdl == 0 || recid > 2*blk_per_trk)
3374 rq_for_each_segment(bv, req, iter) {
3375 dst = page_address(bv->bv_page) + bv->bv_offset;
3376 for (off = 0; off < bv->bv_len; off += blksize) {
3377 /* Skip locate record. */
3378 if (private->uses_cdl && recid <= 2*blk_per_trk)
3381 if (ccw->flags & CCW_FLAG_IDA)
3382 cda = *((char **)((addr_t) ccw->cda));
3384 cda = (char *)((addr_t) ccw->cda);
3386 if (rq_data_dir(req) == READ)
3387 memcpy(dst, cda, bv->bv_len);
3388 kmem_cache_free(dasd_page_cache,
3389 (void *)((addr_t)cda & PAGE_MASK));
3398 status = cqr->status == DASD_CQR_DONE;
3399 dasd_sfree_request(cqr, cqr->memdev);
3404 * Modify ccw/tcw in cqr so it can be started on a base device.
3406 * Note that this is not enough to restart the cqr!
3407 * Either reset cqr->startdev as well (summary unit check handling)
3408 * or restart via separate cqr (as in ERP handling).
3410 void dasd_eckd_reset_ccw_to_base_io(struct dasd_ccw_req *cqr)
3413 struct PFX_eckd_data *pfxdata;
3418 if (cqr->cpmode == 1) {
3420 tccb = tcw_get_tccb(tcw);
3421 dcw = (struct dcw *)&tccb->tca[0];
3422 pfxdata = (struct PFX_eckd_data *)&dcw->cd[0];
3423 pfxdata->validity.verify_base = 0;
3424 pfxdata->validity.hyper_pav = 0;
3427 pfxdata = cqr->data;
3428 if (ccw->cmd_code == DASD_ECKD_CCW_PFX) {
3429 pfxdata->validity.verify_base = 0;
3430 pfxdata->validity.hyper_pav = 0;
3435 #define DASD_ECKD_CHANQ_MAX_SIZE 4
3437 static struct dasd_ccw_req *dasd_eckd_build_alias_cp(struct dasd_device *base,
3438 struct dasd_block *block,
3439 struct request *req)
3441 struct dasd_eckd_private *private;
3442 struct dasd_device *startdev;
3443 unsigned long flags;
3444 struct dasd_ccw_req *cqr;
3446 startdev = dasd_alias_get_start_dev(base);
3449 private = (struct dasd_eckd_private *) startdev->private;
3450 if (private->count >= DASD_ECKD_CHANQ_MAX_SIZE)
3451 return ERR_PTR(-EBUSY);
3453 spin_lock_irqsave(get_ccwdev_lock(startdev->cdev), flags);
3455 if ((base->features & DASD_FEATURE_USERAW))
3456 cqr = dasd_raw_build_cp(startdev, block, req);
3458 cqr = dasd_eckd_build_cp(startdev, block, req);
3461 spin_unlock_irqrestore(get_ccwdev_lock(startdev->cdev), flags);
3465 static int dasd_eckd_free_alias_cp(struct dasd_ccw_req *cqr,
3466 struct request *req)
3468 struct dasd_eckd_private *private;
3469 unsigned long flags;
3471 spin_lock_irqsave(get_ccwdev_lock(cqr->memdev->cdev), flags);
3472 private = (struct dasd_eckd_private *) cqr->memdev->private;
3474 spin_unlock_irqrestore(get_ccwdev_lock(cqr->memdev->cdev), flags);
3475 return dasd_eckd_free_cp(cqr, req);
3479 dasd_eckd_fill_info(struct dasd_device * device,
3480 struct dasd_information2_t * info)
3482 struct dasd_eckd_private *private;
3484 private = (struct dasd_eckd_private *) device->private;
3485 info->label_block = 2;
3486 info->FBA_layout = private->uses_cdl ? 0 : 1;
3487 info->format = private->uses_cdl ? DASD_FORMAT_CDL : DASD_FORMAT_LDL;
3488 info->characteristics_size = sizeof(struct dasd_eckd_characteristics);
3489 memcpy(info->characteristics, &private->rdc_data,
3490 sizeof(struct dasd_eckd_characteristics));
3491 info->confdata_size = min((unsigned long)private->conf_len,
3492 sizeof(info->configuration_data));
3493 memcpy(info->configuration_data, private->conf_data,
3494 info->confdata_size);
3499 * SECTION: ioctl functions for eckd devices.
3503 * Release device ioctl.
3504 * Buils a channel programm to releases a prior reserved
3505 * (see dasd_eckd_reserve) device.
3508 dasd_eckd_release(struct dasd_device *device)
3510 struct dasd_ccw_req *cqr;
3515 if (!capable(CAP_SYS_ADMIN))
3519 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1, 32, device);
3521 mutex_lock(&dasd_reserve_mutex);
3523 cqr = &dasd_reserve_req->cqr;
3524 memset(cqr, 0, sizeof(*cqr));
3525 memset(&dasd_reserve_req->ccw, 0,
3526 sizeof(dasd_reserve_req->ccw));
3527 cqr->cpaddr = &dasd_reserve_req->ccw;
3528 cqr->data = &dasd_reserve_req->data;
3529 cqr->magic = DASD_ECKD_MAGIC;
3532 ccw->cmd_code = DASD_ECKD_CCW_RELEASE;
3533 ccw->flags |= CCW_FLAG_SLI;
3535 ccw->cda = (__u32)(addr_t) cqr->data;
3536 cqr->startdev = device;
3537 cqr->memdev = device;
3538 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
3539 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
3540 cqr->retries = 2; /* set retry counter to enable basic ERP */
3541 cqr->expires = 2 * HZ;
3542 cqr->buildclk = get_tod_clock();
3543 cqr->status = DASD_CQR_FILLED;
3545 rc = dasd_sleep_on_immediatly(cqr);
3547 clear_bit(DASD_FLAG_IS_RESERVED, &device->flags);
3550 mutex_unlock(&dasd_reserve_mutex);
3552 dasd_sfree_request(cqr, cqr->memdev);
3557 * Reserve device ioctl.
3558 * Options are set to 'synchronous wait for interrupt' and
3559 * 'timeout the request'. This leads to a terminate IO if
3560 * the interrupt is outstanding for a certain time.
3563 dasd_eckd_reserve(struct dasd_device *device)
3565 struct dasd_ccw_req *cqr;
3570 if (!capable(CAP_SYS_ADMIN))
3574 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1, 32, device);
3576 mutex_lock(&dasd_reserve_mutex);
3578 cqr = &dasd_reserve_req->cqr;
3579 memset(cqr, 0, sizeof(*cqr));
3580 memset(&dasd_reserve_req->ccw, 0,
3581 sizeof(dasd_reserve_req->ccw));
3582 cqr->cpaddr = &dasd_reserve_req->ccw;
3583 cqr->data = &dasd_reserve_req->data;
3584 cqr->magic = DASD_ECKD_MAGIC;
3587 ccw->cmd_code = DASD_ECKD_CCW_RESERVE;
3588 ccw->flags |= CCW_FLAG_SLI;
3590 ccw->cda = (__u32)(addr_t) cqr->data;
3591 cqr->startdev = device;
3592 cqr->memdev = device;
3593 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
3594 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
3595 cqr->retries = 2; /* set retry counter to enable basic ERP */
3596 cqr->expires = 2 * HZ;
3597 cqr->buildclk = get_tod_clock();
3598 cqr->status = DASD_CQR_FILLED;
3600 rc = dasd_sleep_on_immediatly(cqr);
3602 set_bit(DASD_FLAG_IS_RESERVED, &device->flags);
3605 mutex_unlock(&dasd_reserve_mutex);
3607 dasd_sfree_request(cqr, cqr->memdev);
3612 * Steal lock ioctl - unconditional reserve device.
3613 * Buils a channel programm to break a device's reservation.
3614 * (unconditional reserve)
3617 dasd_eckd_steal_lock(struct dasd_device *device)
3619 struct dasd_ccw_req *cqr;
3624 if (!capable(CAP_SYS_ADMIN))
3628 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1, 32, device);
3630 mutex_lock(&dasd_reserve_mutex);
3632 cqr = &dasd_reserve_req->cqr;
3633 memset(cqr, 0, sizeof(*cqr));
3634 memset(&dasd_reserve_req->ccw, 0,
3635 sizeof(dasd_reserve_req->ccw));
3636 cqr->cpaddr = &dasd_reserve_req->ccw;
3637 cqr->data = &dasd_reserve_req->data;
3638 cqr->magic = DASD_ECKD_MAGIC;
3641 ccw->cmd_code = DASD_ECKD_CCW_SLCK;
3642 ccw->flags |= CCW_FLAG_SLI;
3644 ccw->cda = (__u32)(addr_t) cqr->data;
3645 cqr->startdev = device;
3646 cqr->memdev = device;
3647 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
3648 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
3649 cqr->retries = 2; /* set retry counter to enable basic ERP */
3650 cqr->expires = 2 * HZ;
3651 cqr->buildclk = get_tod_clock();
3652 cqr->status = DASD_CQR_FILLED;
3654 rc = dasd_sleep_on_immediatly(cqr);
3656 set_bit(DASD_FLAG_IS_RESERVED, &device->flags);
3659 mutex_unlock(&dasd_reserve_mutex);
3661 dasd_sfree_request(cqr, cqr->memdev);
3666 * SNID - Sense Path Group ID
3667 * This ioctl may be used in situations where I/O is stalled due to
3668 * a reserve, so if the normal dasd_smalloc_request fails, we use the
3669 * preallocated dasd_reserve_req.
3671 static int dasd_eckd_snid(struct dasd_device *device,
3674 struct dasd_ccw_req *cqr;
3678 struct dasd_snid_ioctl_data usrparm;
3680 if (!capable(CAP_SYS_ADMIN))
3683 if (copy_from_user(&usrparm, argp, sizeof(usrparm)))
3687 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1,
3688 sizeof(struct dasd_snid_data), device);
3690 mutex_lock(&dasd_reserve_mutex);
3692 cqr = &dasd_reserve_req->cqr;
3693 memset(cqr, 0, sizeof(*cqr));
3694 memset(&dasd_reserve_req->ccw, 0,
3695 sizeof(dasd_reserve_req->ccw));
3696 cqr->cpaddr = &dasd_reserve_req->ccw;
3697 cqr->data = &dasd_reserve_req->data;
3698 cqr->magic = DASD_ECKD_MAGIC;
3701 ccw->cmd_code = DASD_ECKD_CCW_SNID;
3702 ccw->flags |= CCW_FLAG_SLI;
3704 ccw->cda = (__u32)(addr_t) cqr->data;
3705 cqr->startdev = device;
3706 cqr->memdev = device;
3707 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
3708 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
3709 set_bit(DASD_CQR_ALLOW_SLOCK, &cqr->flags);
3711 cqr->expires = 10 * HZ;
3712 cqr->buildclk = get_tod_clock();
3713 cqr->status = DASD_CQR_FILLED;
3714 cqr->lpm = usrparm.path_mask;
3716 rc = dasd_sleep_on_immediatly(cqr);
3717 /* verify that I/O processing didn't modify the path mask */
3718 if (!rc && usrparm.path_mask && (cqr->lpm != usrparm.path_mask))
3721 usrparm.data = *((struct dasd_snid_data *)cqr->data);
3722 if (copy_to_user(argp, &usrparm, sizeof(usrparm)))
3727 mutex_unlock(&dasd_reserve_mutex);
3729 dasd_sfree_request(cqr, cqr->memdev);
3734 * Read performance statistics
3737 dasd_eckd_performance(struct dasd_device *device, void __user *argp)
3739 struct dasd_psf_prssd_data *prssdp;
3740 struct dasd_rssd_perf_stats_t *stats;
3741 struct dasd_ccw_req *cqr;
3745 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */,
3746 (sizeof(struct dasd_psf_prssd_data) +
3747 sizeof(struct dasd_rssd_perf_stats_t)),
3750 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
3751 "Could not allocate initialization request");
3752 return PTR_ERR(cqr);
3754 cqr->startdev = device;
3755 cqr->memdev = device;
3757 clear_bit(DASD_CQR_FLAGS_USE_ERP, &cqr->flags);
3758 cqr->expires = 10 * HZ;
3760 /* Prepare for Read Subsystem Data */
3761 prssdp = (struct dasd_psf_prssd_data *) cqr->data;
3762 memset(prssdp, 0, sizeof(struct dasd_psf_prssd_data));
3763 prssdp->order = PSF_ORDER_PRSSD;
3764 prssdp->suborder = 0x01; /* Performance Statistics */
3765 prssdp->varies[1] = 0x01; /* Perf Statistics for the Subsystem */
3768 ccw->cmd_code = DASD_ECKD_CCW_PSF;
3769 ccw->count = sizeof(struct dasd_psf_prssd_data);
3770 ccw->flags |= CCW_FLAG_CC;
3771 ccw->cda = (__u32)(addr_t) prssdp;
3773 /* Read Subsystem Data - Performance Statistics */
3774 stats = (struct dasd_rssd_perf_stats_t *) (prssdp + 1);
3775 memset(stats, 0, sizeof(struct dasd_rssd_perf_stats_t));
3778 ccw->cmd_code = DASD_ECKD_CCW_RSSD;
3779 ccw->count = sizeof(struct dasd_rssd_perf_stats_t);
3780 ccw->cda = (__u32)(addr_t) stats;
3782 cqr->buildclk = get_tod_clock();
3783 cqr->status = DASD_CQR_FILLED;
3784 rc = dasd_sleep_on(cqr);
3786 prssdp = (struct dasd_psf_prssd_data *) cqr->data;
3787 stats = (struct dasd_rssd_perf_stats_t *) (prssdp + 1);
3788 if (copy_to_user(argp, stats,
3789 sizeof(struct dasd_rssd_perf_stats_t)))
3792 dasd_sfree_request(cqr, cqr->memdev);
3797 * Get attributes (cache operations)
3798 * Returnes the cache attributes used in Define Extend (DE).
3801 dasd_eckd_get_attrib(struct dasd_device *device, void __user *argp)
3803 struct dasd_eckd_private *private =
3804 (struct dasd_eckd_private *)device->private;
3805 struct attrib_data_t attrib = private->attrib;
3808 if (!capable(CAP_SYS_ADMIN))
3814 if (copy_to_user(argp, (long *) &attrib,
3815 sizeof(struct attrib_data_t)))
3822 * Set attributes (cache operations)
3823 * Stores the attributes for cache operation to be used in Define Extend (DE).
3826 dasd_eckd_set_attrib(struct dasd_device *device, void __user *argp)
3828 struct dasd_eckd_private *private =
3829 (struct dasd_eckd_private *)device->private;
3830 struct attrib_data_t attrib;
3832 if (!capable(CAP_SYS_ADMIN))
3837 if (copy_from_user(&attrib, argp, sizeof(struct attrib_data_t)))
3839 private->attrib = attrib;
3841 dev_info(&device->cdev->dev,
3842 "The DASD cache mode was set to %x (%i cylinder prestage)\n",
3843 private->attrib.operation, private->attrib.nr_cyl);
3848 * Issue syscall I/O to EMC Symmetrix array.
3849 * CCWs are PSF and RSSD
3851 static int dasd_symm_io(struct dasd_device *device, void __user *argp)
3853 struct dasd_symmio_parms usrparm;
3854 char *psf_data, *rssd_result;
3855 struct dasd_ccw_req *cqr;
3860 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RAWIO))
3864 /* Copy parms from caller */
3866 if (copy_from_user(&usrparm, argp, sizeof(usrparm)))
3868 if (is_compat_task() || sizeof(long) == 4) {
3869 /* Make sure pointers are sane even on 31 bit. */
3871 if ((usrparm.psf_data >> 32) != 0)
3873 if ((usrparm.rssd_result >> 32) != 0)
3875 usrparm.psf_data &= 0x7fffffffULL;
3876 usrparm.rssd_result &= 0x7fffffffULL;
3878 /* alloc I/O data area */
3879 psf_data = kzalloc(usrparm.psf_data_len, GFP_KERNEL | GFP_DMA);
3880 rssd_result = kzalloc(usrparm.rssd_result_len, GFP_KERNEL | GFP_DMA);
3881 if (!psf_data || !rssd_result) {
3886 /* get syscall header from user space */
3888 if (copy_from_user(psf_data,
3889 (void __user *)(unsigned long) usrparm.psf_data,
3890 usrparm.psf_data_len))
3895 /* setup CCWs for PSF + RSSD */
3896 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 2 , 0, device);
3898 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
3899 "Could not allocate initialization request");
3904 cqr->startdev = device;
3905 cqr->memdev = device;
3907 cqr->expires = 10 * HZ;
3908 cqr->buildclk = get_tod_clock();
3909 cqr->status = DASD_CQR_FILLED;
3911 /* Build the ccws */
3915 ccw->cmd_code = DASD_ECKD_CCW_PSF;
3916 ccw->count = usrparm.psf_data_len;
3917 ccw->flags |= CCW_FLAG_CC;
3918 ccw->cda = (__u32)(addr_t) psf_data;
3923 ccw->cmd_code = DASD_ECKD_CCW_RSSD;
3924 ccw->count = usrparm.rssd_result_len;
3925 ccw->flags = CCW_FLAG_SLI ;
3926 ccw->cda = (__u32)(addr_t) rssd_result;
3928 rc = dasd_sleep_on(cqr);
3933 if (copy_to_user((void __user *)(unsigned long) usrparm.rssd_result,
3934 rssd_result, usrparm.rssd_result_len))
3939 dasd_sfree_request(cqr, cqr->memdev);
3944 DBF_DEV_EVENT(DBF_WARNING, device,
3945 "Symmetrix ioctl (0x%02x 0x%02x): rc=%d",
3946 (int) psf0, (int) psf1, rc);
3951 dasd_eckd_ioctl(struct dasd_block *block, unsigned int cmd, void __user *argp)
3953 struct dasd_device *device = block->base;
3957 return dasd_eckd_get_attrib(device, argp);
3959 return dasd_eckd_set_attrib(device, argp);
3961 return dasd_eckd_performance(device, argp);
3963 return dasd_eckd_release(device);
3965 return dasd_eckd_reserve(device);
3967 return dasd_eckd_steal_lock(device);
3969 return dasd_eckd_snid(device, argp);
3971 return dasd_symm_io(device, argp);
3978 * Dump the range of CCWs into 'page' buffer
3979 * and return number of printed chars.
3982 dasd_eckd_dump_ccw_range(struct ccw1 *from, struct ccw1 *to, char *page)
3988 while (from <= to) {
3989 len += sprintf(page + len, PRINTK_HEADER
3990 " CCW %p: %08X %08X DAT:",
3991 from, ((int *) from)[0], ((int *) from)[1]);
3993 /* get pointer to data (consider IDALs) */
3994 if (from->flags & CCW_FLAG_IDA)
3995 datap = (char *) *((addr_t *) (addr_t) from->cda);
3997 datap = (char *) ((addr_t) from->cda);
3999 /* dump data (max 32 bytes) */
4000 for (count = 0; count < from->count && count < 32; count++) {
4001 if (count % 8 == 0) len += sprintf(page + len, " ");
4002 if (count % 4 == 0) len += sprintf(page + len, " ");
4003 len += sprintf(page + len, "%02x", datap[count]);
4005 len += sprintf(page + len, "\n");
4012 dasd_eckd_dump_sense_dbf(struct dasd_device *device, struct irb *irb,
4018 sense = (u64 *) dasd_get_sense(irb);
4019 stat = (u64 *) &irb->scsw;
4021 DBF_DEV_EVENT(DBF_EMERG, device, "%s: %016llx %08x : "
4022 "%016llx %016llx %016llx %016llx",
4023 reason, *stat, *((u32 *) (stat + 1)),
4024 sense[0], sense[1], sense[2], sense[3]);
4026 DBF_DEV_EVENT(DBF_EMERG, device, "%s: %016llx %08x : %s",
4027 reason, *stat, *((u32 *) (stat + 1)),
4033 * Print sense data and related channel program.
4034 * Parts are printed because printk buffer is only 1024 bytes.
4036 static void dasd_eckd_dump_sense_ccw(struct dasd_device *device,
4037 struct dasd_ccw_req *req, struct irb *irb)
4040 struct ccw1 *first, *last, *fail, *from, *to;
4043 page = (char *) get_zeroed_page(GFP_ATOMIC);
4045 DBF_DEV_EVENT(DBF_WARNING, device, "%s",
4046 "No memory to dump sense data\n");
4049 /* dump the sense data */
4050 len = sprintf(page, PRINTK_HEADER
4051 " I/O status report for device %s:\n",
4052 dev_name(&device->cdev->dev));
4053 len += sprintf(page + len, PRINTK_HEADER
4054 " in req: %p CC:%02X FC:%02X AC:%02X SC:%02X DS:%02X "
4056 req, scsw_cc(&irb->scsw), scsw_fctl(&irb->scsw),
4057 scsw_actl(&irb->scsw), scsw_stctl(&irb->scsw),
4058 scsw_dstat(&irb->scsw), scsw_cstat(&irb->scsw),
4059 req ? req->intrc : 0);
4060 len += sprintf(page + len, PRINTK_HEADER
4061 " device %s: Failing CCW: %p\n",
4062 dev_name(&device->cdev->dev),
4063 (void *) (addr_t) irb->scsw.cmd.cpa);
4064 if (irb->esw.esw0.erw.cons) {
4065 for (sl = 0; sl < 4; sl++) {
4066 len += sprintf(page + len, PRINTK_HEADER
4067 " Sense(hex) %2d-%2d:",
4068 (8 * sl), ((8 * sl) + 7));
4070 for (sct = 0; sct < 8; sct++) {
4071 len += sprintf(page + len, " %02x",
4072 irb->ecw[8 * sl + sct]);
4074 len += sprintf(page + len, "\n");
4077 if (irb->ecw[27] & DASD_SENSE_BIT_0) {
4078 /* 24 Byte Sense Data */
4079 sprintf(page + len, PRINTK_HEADER
4080 " 24 Byte: %x MSG %x, "
4081 "%s MSGb to SYSOP\n",
4082 irb->ecw[7] >> 4, irb->ecw[7] & 0x0f,
4083 irb->ecw[1] & 0x10 ? "" : "no");
4085 /* 32 Byte Sense Data */
4086 sprintf(page + len, PRINTK_HEADER
4087 " 32 Byte: Format: %x "
4088 "Exception class %x\n",
4089 irb->ecw[6] & 0x0f, irb->ecw[22] >> 4);
4092 sprintf(page + len, PRINTK_HEADER
4093 " SORRY - NO VALID SENSE AVAILABLE\n");
4095 printk(KERN_ERR "%s", page);
4098 /* req == NULL for unsolicited interrupts */
4099 /* dump the Channel Program (max 140 Bytes per line) */
4100 /* Count CCW and print first CCWs (maximum 1024 % 140 = 7) */
4101 first = req->cpaddr;
4102 for (last = first; last->flags & (CCW_FLAG_CC | CCW_FLAG_DC); last++);
4103 to = min(first + 6, last);
4104 len = sprintf(page, PRINTK_HEADER
4105 " Related CP in req: %p\n", req);
4106 dasd_eckd_dump_ccw_range(first, to, page + len);
4107 printk(KERN_ERR "%s", page);
4109 /* print failing CCW area (maximum 4) */
4110 /* scsw->cda is either valid or zero */
4113 fail = (struct ccw1 *)(addr_t)
4114 irb->scsw.cmd.cpa; /* failing CCW */
4115 if (from < fail - 2) {
4116 from = fail - 2; /* there is a gap - print header */
4117 len += sprintf(page, PRINTK_HEADER "......\n");
4119 to = min(fail + 1, last);
4120 len += dasd_eckd_dump_ccw_range(from, to, page + len);
4122 /* print last CCWs (maximum 2) */
4123 from = max(from, ++to);
4124 if (from < last - 1) {
4125 from = last - 1; /* there is a gap - print header */
4126 len += sprintf(page + len, PRINTK_HEADER "......\n");
4128 len += dasd_eckd_dump_ccw_range(from, last, page + len);
4130 printk(KERN_ERR "%s", page);
4132 free_page((unsigned long) page);
4137 * Print sense data from a tcw.
4139 static void dasd_eckd_dump_sense_tcw(struct dasd_device *device,
4140 struct dasd_ccw_req *req, struct irb *irb)
4143 int len, sl, sct, residual;
4147 page = (char *) get_zeroed_page(GFP_ATOMIC);
4149 DBF_DEV_EVENT(DBF_WARNING, device, " %s",
4150 "No memory to dump sense data");
4153 /* dump the sense data */
4154 len = sprintf(page, PRINTK_HEADER
4155 " I/O status report for device %s:\n",
4156 dev_name(&device->cdev->dev));
4157 len += sprintf(page + len, PRINTK_HEADER
4158 " in req: %p CC:%02X FC:%02X AC:%02X SC:%02X DS:%02X "
4159 "CS:%02X fcxs:%02X schxs:%02X RC:%d\n",
4160 req, scsw_cc(&irb->scsw), scsw_fctl(&irb->scsw),
4161 scsw_actl(&irb->scsw), scsw_stctl(&irb->scsw),
4162 scsw_dstat(&irb->scsw), scsw_cstat(&irb->scsw),
4163 irb->scsw.tm.fcxs, irb->scsw.tm.schxs,
4164 req ? req->intrc : 0);
4165 len += sprintf(page + len, PRINTK_HEADER
4166 " device %s: Failing TCW: %p\n",
4167 dev_name(&device->cdev->dev),
4168 (void *) (addr_t) irb->scsw.tm.tcw);
4172 if (irb->scsw.tm.tcw && (irb->scsw.tm.fcxs & 0x01))
4174 (struct tcw *)(unsigned long)irb->scsw.tm.tcw);
4177 len += sprintf(page + len, PRINTK_HEADER
4178 " tsb->length %d\n", tsb->length);
4179 len += sprintf(page + len, PRINTK_HEADER
4180 " tsb->flags %x\n", tsb->flags);
4181 len += sprintf(page + len, PRINTK_HEADER
4182 " tsb->dcw_offset %d\n", tsb->dcw_offset);
4183 len += sprintf(page + len, PRINTK_HEADER
4184 " tsb->count %d\n", tsb->count);
4185 residual = tsb->count - 28;
4186 len += sprintf(page + len, PRINTK_HEADER
4187 " residual %d\n", residual);
4189 switch (tsb->flags & 0x07) {
4190 case 1: /* tsa_iostat */
4191 len += sprintf(page + len, PRINTK_HEADER
4192 " tsb->tsa.iostat.dev_time %d\n",
4193 tsb->tsa.iostat.dev_time);
4194 len += sprintf(page + len, PRINTK_HEADER
4195 " tsb->tsa.iostat.def_time %d\n",
4196 tsb->tsa.iostat.def_time);
4197 len += sprintf(page + len, PRINTK_HEADER
4198 " tsb->tsa.iostat.queue_time %d\n",
4199 tsb->tsa.iostat.queue_time);
4200 len += sprintf(page + len, PRINTK_HEADER
4201 " tsb->tsa.iostat.dev_busy_time %d\n",
4202 tsb->tsa.iostat.dev_busy_time);
4203 len += sprintf(page + len, PRINTK_HEADER
4204 " tsb->tsa.iostat.dev_act_time %d\n",
4205 tsb->tsa.iostat.dev_act_time);
4206 sense = tsb->tsa.iostat.sense;
4208 case 2: /* ts_ddpc */
4209 len += sprintf(page + len, PRINTK_HEADER
4210 " tsb->tsa.ddpc.rc %d\n", tsb->tsa.ddpc.rc);
4211 for (sl = 0; sl < 2; sl++) {
4212 len += sprintf(page + len, PRINTK_HEADER
4213 " tsb->tsa.ddpc.rcq %2d-%2d: ",
4214 (8 * sl), ((8 * sl) + 7));
4215 rcq = tsb->tsa.ddpc.rcq;
4216 for (sct = 0; sct < 8; sct++) {
4217 len += sprintf(page + len, " %02x",
4220 len += sprintf(page + len, "\n");
4222 sense = tsb->tsa.ddpc.sense;
4224 case 3: /* tsa_intrg */
4225 len += sprintf(page + len, PRINTK_HEADER
4226 " tsb->tsa.intrg.: not supportet yet\n");
4231 for (sl = 0; sl < 4; sl++) {
4232 len += sprintf(page + len, PRINTK_HEADER
4233 " Sense(hex) %2d-%2d:",
4234 (8 * sl), ((8 * sl) + 7));
4235 for (sct = 0; sct < 8; sct++) {
4236 len += sprintf(page + len, " %02x",
4237 sense[8 * sl + sct]);
4239 len += sprintf(page + len, "\n");
4242 if (sense[27] & DASD_SENSE_BIT_0) {
4243 /* 24 Byte Sense Data */
4244 sprintf(page + len, PRINTK_HEADER
4245 " 24 Byte: %x MSG %x, "
4246 "%s MSGb to SYSOP\n",
4247 sense[7] >> 4, sense[7] & 0x0f,
4248 sense[1] & 0x10 ? "" : "no");
4250 /* 32 Byte Sense Data */
4251 sprintf(page + len, PRINTK_HEADER
4252 " 32 Byte: Format: %x "
4253 "Exception class %x\n",
4254 sense[6] & 0x0f, sense[22] >> 4);
4257 sprintf(page + len, PRINTK_HEADER
4258 " SORRY - NO VALID SENSE AVAILABLE\n");
4261 sprintf(page + len, PRINTK_HEADER
4262 " SORRY - NO TSB DATA AVAILABLE\n");
4264 printk(KERN_ERR "%s", page);
4265 free_page((unsigned long) page);
4268 static void dasd_eckd_dump_sense(struct dasd_device *device,
4269 struct dasd_ccw_req *req, struct irb *irb)
4271 if (scsw_is_tm(&irb->scsw))
4272 dasd_eckd_dump_sense_tcw(device, req, irb);
4274 dasd_eckd_dump_sense_ccw(device, req, irb);
4277 static int dasd_eckd_pm_freeze(struct dasd_device *device)
4280 * the device should be disconnected from our LCU structure
4281 * on restore we will reconnect it and reread LCU specific
4282 * information like PAV support that might have changed
4284 dasd_alias_remove_device(device);
4285 dasd_alias_disconnect_device_from_lcu(device);
4290 static int dasd_eckd_restore_device(struct dasd_device *device)
4292 struct dasd_eckd_private *private;
4293 struct dasd_eckd_characteristics temp_rdc_data;
4295 struct dasd_uid temp_uid;
4296 unsigned long flags;
4297 unsigned long cqr_flags = 0;
4299 private = (struct dasd_eckd_private *) device->private;
4301 /* Read Configuration Data */
4302 dasd_eckd_read_conf(device);
4304 dasd_eckd_get_uid(device, &temp_uid);
4305 /* Generate device unique id */
4306 rc = dasd_eckd_generate_uid(device);
4307 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
4308 if (memcmp(&private->uid, &temp_uid, sizeof(struct dasd_uid)) != 0)
4309 dev_err(&device->cdev->dev, "The UID of the DASD has "
4311 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
4315 /* register lcu with alias handling, enable PAV if this is a new lcu */
4316 rc = dasd_alias_make_device_known_to_lcu(device);
4320 set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr_flags);
4321 dasd_eckd_validate_server(device, cqr_flags);
4323 /* RE-Read Configuration Data */
4324 dasd_eckd_read_conf(device);
4326 /* Read Feature Codes */
4327 dasd_eckd_read_features(device);
4329 /* Read Device Characteristics */
4330 rc = dasd_generic_read_dev_chars(device, DASD_ECKD_MAGIC,
4331 &temp_rdc_data, 64);
4333 DBF_EVENT_DEVID(DBF_WARNING, device->cdev,
4334 "Read device characteristic failed, rc=%d", rc);
4337 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
4338 memcpy(&private->rdc_data, &temp_rdc_data, sizeof(temp_rdc_data));
4339 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
4341 /* add device to alias management */
4342 dasd_alias_add_device(device);
4350 static int dasd_eckd_reload_device(struct dasd_device *device)
4352 struct dasd_eckd_private *private;
4355 struct dasd_uid uid;
4356 unsigned long flags;
4358 private = (struct dasd_eckd_private *) device->private;
4360 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
4361 old_base = private->uid.base_unit_addr;
4362 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
4364 /* Read Configuration Data */
4365 rc = dasd_eckd_read_conf(device);
4369 rc = dasd_eckd_generate_uid(device);
4373 * update unit address configuration and
4374 * add device to alias management
4376 dasd_alias_update_add_device(device);
4378 dasd_eckd_get_uid(device, &uid);
4380 if (old_base != uid.base_unit_addr) {
4381 if (strlen(uid.vduit) > 0)
4382 snprintf(print_uid, sizeof(print_uid),
4383 "%s.%s.%04x.%02x.%s", uid.vendor, uid.serial,
4384 uid.ssid, uid.base_unit_addr, uid.vduit);
4386 snprintf(print_uid, sizeof(print_uid),
4387 "%s.%s.%04x.%02x", uid.vendor, uid.serial,
4388 uid.ssid, uid.base_unit_addr);
4390 dev_info(&device->cdev->dev,
4391 "An Alias device was reassigned to a new base device "
4392 "with UID: %s\n", print_uid);
4400 static struct ccw_driver dasd_eckd_driver = {
4402 .name = "dasd-eckd",
4403 .owner = THIS_MODULE,
4405 .ids = dasd_eckd_ids,
4406 .probe = dasd_eckd_probe,
4407 .remove = dasd_generic_remove,
4408 .set_offline = dasd_generic_set_offline,
4409 .set_online = dasd_eckd_set_online,
4410 .notify = dasd_generic_notify,
4411 .path_event = dasd_generic_path_event,
4412 .shutdown = dasd_generic_shutdown,
4413 .freeze = dasd_generic_pm_freeze,
4414 .thaw = dasd_generic_restore_device,
4415 .restore = dasd_generic_restore_device,
4416 .uc_handler = dasd_generic_uc_handler,
4417 .int_class = IRQIO_DAS,
4421 * max_blocks is dependent on the amount of storage that is available
4422 * in the static io buffer for each device. Currently each device has
4423 * 8192 bytes (=2 pages). For 64 bit one dasd_mchunkt_t structure has
4424 * 24 bytes, the struct dasd_ccw_req has 136 bytes and each block can use
4425 * up to 16 bytes (8 for the ccw and 8 for the idal pointer). In
4426 * addition we have one define extent ccw + 16 bytes of data and one
4427 * locate record ccw + 16 bytes of data. That makes:
4428 * (8192 - 24 - 136 - 8 - 16 - 8 - 16) / 16 = 499 blocks at maximum.
4429 * We want to fit two into the available memory so that we can immediately
4430 * start the next request if one finishes off. That makes 249.5 blocks
4431 * for one request. Give a little safety and the result is 240.
4433 static struct dasd_discipline dasd_eckd_discipline = {
4434 .owner = THIS_MODULE,
4438 .check_device = dasd_eckd_check_characteristics,
4439 .uncheck_device = dasd_eckd_uncheck_device,
4440 .do_analysis = dasd_eckd_do_analysis,
4441 .verify_path = dasd_eckd_verify_path,
4442 .basic_to_ready = dasd_eckd_basic_to_ready,
4443 .online_to_ready = dasd_eckd_online_to_ready,
4444 .ready_to_basic = dasd_eckd_ready_to_basic,
4445 .fill_geometry = dasd_eckd_fill_geometry,
4446 .start_IO = dasd_start_IO,
4447 .term_IO = dasd_term_IO,
4448 .handle_terminated_request = dasd_eckd_handle_terminated_request,
4449 .format_device = dasd_eckd_format_device,
4450 .erp_action = dasd_eckd_erp_action,
4451 .erp_postaction = dasd_eckd_erp_postaction,
4452 .check_for_device_change = dasd_eckd_check_for_device_change,
4453 .build_cp = dasd_eckd_build_alias_cp,
4454 .free_cp = dasd_eckd_free_alias_cp,
4455 .dump_sense = dasd_eckd_dump_sense,
4456 .dump_sense_dbf = dasd_eckd_dump_sense_dbf,
4457 .fill_info = dasd_eckd_fill_info,
4458 .ioctl = dasd_eckd_ioctl,
4459 .freeze = dasd_eckd_pm_freeze,
4460 .restore = dasd_eckd_restore_device,
4461 .reload = dasd_eckd_reload_device,
4462 .get_uid = dasd_eckd_get_uid,
4463 .kick_validate = dasd_eckd_kick_validate_server,
4467 dasd_eckd_init(void)
4471 ASCEBC(dasd_eckd_discipline.ebcname, 4);
4472 dasd_reserve_req = kmalloc(sizeof(*dasd_reserve_req),
4473 GFP_KERNEL | GFP_DMA);
4474 if (!dasd_reserve_req)
4476 path_verification_worker = kmalloc(sizeof(*path_verification_worker),
4477 GFP_KERNEL | GFP_DMA);
4478 if (!path_verification_worker) {
4479 kfree(dasd_reserve_req);
4482 ret = ccw_driver_register(&dasd_eckd_driver);
4484 wait_for_device_probe();
4486 kfree(path_verification_worker);
4487 kfree(dasd_reserve_req);
4493 dasd_eckd_cleanup(void)
4495 ccw_driver_unregister(&dasd_eckd_driver);
4496 kfree(path_verification_worker);
4497 kfree(dasd_reserve_req);
4500 module_init(dasd_eckd_init);
4501 module_exit(dasd_eckd_cleanup);