1 // SPDX-License-Identifier: GPL-2.0
3 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
4 * Bugreports.to..: <Linux390@de.ibm.com>
5 * Copyright IBM Corp. 1999, 2009
8 #define KMSG_COMPONENT "dasd-fba"
10 #include <linux/stddef.h>
11 #include <linux/kernel.h>
12 #include <asm/debug.h>
14 #include <linux/slab.h>
15 #include <linux/hdreg.h> /* HDIO_GETGEO */
16 #include <linux/bio.h>
17 #include <linux/module.h>
18 #include <linux/init.h>
20 #include <asm/idals.h>
21 #include <asm/ebcdic.h>
23 #include <asm/ccwdev.h>
30 #endif /* PRINTK_HEADER */
31 #define PRINTK_HEADER "dasd(fba):"
33 #define FBA_DEFAULT_RETRIES 32
35 #define DASD_FBA_CCW_WRITE 0x41
36 #define DASD_FBA_CCW_READ 0x42
37 #define DASD_FBA_CCW_LOCATE 0x43
38 #define DASD_FBA_CCW_DEFINE_EXTENT 0x63
40 MODULE_LICENSE("GPL");
42 static struct dasd_discipline dasd_fba_discipline
;
44 struct dasd_fba_private
{
45 struct dasd_fba_characteristics rdc_data
;
48 static struct ccw_device_id dasd_fba_ids
[] = {
49 { CCW_DEVICE_DEVTYPE (0x6310, 0, 0x9336, 0), .driver_info
= 0x1},
50 { CCW_DEVICE_DEVTYPE (0x3880, 0, 0x3370, 0), .driver_info
= 0x2},
51 { /* end of list */ },
54 MODULE_DEVICE_TABLE(ccw
, dasd_fba_ids
);
56 static struct ccw_driver dasd_fba_driver
; /* see below */
58 dasd_fba_probe(struct ccw_device
*cdev
)
60 return dasd_generic_probe(cdev
, &dasd_fba_discipline
);
64 dasd_fba_set_online(struct ccw_device
*cdev
)
66 return dasd_generic_set_online(cdev
, &dasd_fba_discipline
);
69 static struct ccw_driver dasd_fba_driver
= {
75 .probe
= dasd_fba_probe
,
76 .remove
= dasd_generic_remove
,
77 .set_offline
= dasd_generic_set_offline
,
78 .set_online
= dasd_fba_set_online
,
79 .notify
= dasd_generic_notify
,
80 .path_event
= dasd_generic_path_event
,
81 .freeze
= dasd_generic_pm_freeze
,
82 .thaw
= dasd_generic_restore_device
,
83 .restore
= dasd_generic_restore_device
,
84 .int_class
= IRQIO_DAS
,
88 define_extent(struct ccw1
* ccw
, struct DE_fba_data
*data
, int rw
,
89 int blksize
, int beg
, int nr
)
91 ccw
->cmd_code
= DASD_FBA_CCW_DEFINE_EXTENT
;
94 ccw
->cda
= (__u32
) __pa(data
);
95 memset(data
, 0, sizeof (struct DE_fba_data
));
97 (data
->mask
).perm
= 0x0;
99 (data
->mask
).perm
= 0x1;
101 data
->mask
.perm
= 0x2;
102 data
->blk_size
= blksize
;
104 data
->ext_end
= nr
- 1;
108 locate_record(struct ccw1
* ccw
, struct LO_fba_data
*data
, int rw
,
109 int block_nr
, int block_ct
)
111 ccw
->cmd_code
= DASD_FBA_CCW_LOCATE
;
114 ccw
->cda
= (__u32
) __pa(data
);
115 memset(data
, 0, sizeof (struct LO_fba_data
));
117 data
->operation
.cmd
= 0x5;
119 data
->operation
.cmd
= 0x6;
121 data
->operation
.cmd
= 0x8;
122 data
->blk_nr
= block_nr
;
123 data
->blk_ct
= block_ct
;
127 dasd_fba_check_characteristics(struct dasd_device
*device
)
129 struct dasd_fba_private
*private = device
->private;
130 struct ccw_device
*cdev
= device
->cdev
;
131 struct dasd_block
*block
;
135 private = kzalloc(sizeof(*private), GFP_KERNEL
| GFP_DMA
);
137 dev_warn(&device
->cdev
->dev
,
138 "Allocating memory for private DASD "
142 device
->private = private;
144 memset(private, 0, sizeof(*private));
146 block
= dasd_alloc_block();
148 DBF_EVENT_DEVID(DBF_WARNING
, cdev
, "%s", "could not allocate "
149 "dasd block structure");
150 device
->private = NULL
;
152 return PTR_ERR(block
);
154 device
->block
= block
;
155 block
->base
= device
;
157 /* Read Device Characteristics */
158 rc
= dasd_generic_read_dev_chars(device
, DASD_FBA_MAGIC
,
159 &private->rdc_data
, 32);
161 DBF_EVENT_DEVID(DBF_WARNING
, cdev
, "Read device "
162 "characteristics returned error %d", rc
);
163 device
->block
= NULL
;
164 dasd_free_block(block
);
165 device
->private = NULL
;
170 device
->default_expires
= DASD_EXPIRES
;
171 device
->default_retries
= FBA_DEFAULT_RETRIES
;
172 dasd_path_set_opm(device
, LPM_ANYPATH
);
174 readonly
= dasd_device_is_ro(device
);
176 set_bit(DASD_FLAG_DEVICE_RO
, &device
->flags
);
178 /* FBA supports discard, set the according feature bit */
179 dasd_set_feature(cdev
, DASD_FEATURE_DISCARD
, 1);
181 dev_info(&device
->cdev
->dev
,
182 "New FBA DASD %04X/%02X (CU %04X/%02X) with %d MB "
188 ((private->rdc_data
.blk_bdsa
*
189 (private->rdc_data
.blk_size
>> 9)) >> 11),
190 private->rdc_data
.blk_size
,
191 readonly
? ", read-only device" : "");
195 static int dasd_fba_do_analysis(struct dasd_block
*block
)
197 struct dasd_fba_private
*private = block
->base
->private;
200 rc
= dasd_check_blocksize(private->rdc_data
.blk_size
);
202 DBF_DEV_EVENT(DBF_WARNING
, block
->base
, "unknown blocksize %d",
203 private->rdc_data
.blk_size
);
206 block
->blocks
= private->rdc_data
.blk_bdsa
;
207 block
->bp_block
= private->rdc_data
.blk_size
;
208 block
->s2b_shift
= 0; /* bits to shift 512 to get a block */
209 for (sb
= 512; sb
< private->rdc_data
.blk_size
; sb
= sb
<< 1)
214 static int dasd_fba_fill_geometry(struct dasd_block
*block
,
215 struct hd_geometry
*geo
)
217 if (dasd_check_blocksize(block
->bp_block
) != 0)
219 geo
->cylinders
= (block
->blocks
<< block
->s2b_shift
) >> 10;
221 geo
->sectors
= 128 >> block
->s2b_shift
;
226 dasd_fba_erp_action(struct dasd_ccw_req
* cqr
)
228 return dasd_default_erp_action
;
232 dasd_fba_erp_postaction(struct dasd_ccw_req
* cqr
)
234 if (cqr
->function
== dasd_default_erp_action
)
235 return dasd_default_erp_postaction
;
237 DBF_DEV_EVENT(DBF_WARNING
, cqr
->startdev
, "unknown ERP action %p",
242 static void dasd_fba_check_for_device_change(struct dasd_device
*device
,
243 struct dasd_ccw_req
*cqr
,
248 /* first of all check for state change pending interrupt */
249 mask
= DEV_STAT_ATTENTION
| DEV_STAT_DEV_END
| DEV_STAT_UNIT_EXCEP
;
250 if ((irb
->scsw
.cmd
.dstat
& mask
) == mask
)
251 dasd_generic_handle_state_change(device
);
256 * Builds a CCW with no data payload
258 static void ccw_write_no_data(struct ccw1
*ccw
)
260 ccw
->cmd_code
= DASD_FBA_CCW_WRITE
;
261 ccw
->flags
|= CCW_FLAG_SLI
;
266 * Builds a CCW that writes only zeroes.
268 static void ccw_write_zero(struct ccw1
*ccw
, int count
)
270 ccw
->cmd_code
= DASD_FBA_CCW_WRITE
;
271 ccw
->flags
|= CCW_FLAG_SLI
;
273 ccw
->cda
= (__u32
) (addr_t
) page_to_phys(ZERO_PAGE(0));
277 * Helper function to count the amount of necessary CCWs within a given range
278 * with 4k alignment and command chaining in mind.
280 static int count_ccws(sector_t first_rec
, sector_t last_rec
,
281 unsigned int blocks_per_page
)
283 sector_t wz_stop
= 0, d_stop
= 0;
287 if (first_rec
% blocks_per_page
!= 0) {
288 wz_stop
= first_rec
+ blocks_per_page
-
289 (first_rec
% blocks_per_page
) - 1;
290 if (wz_stop
> last_rec
)
292 cur_pos
= wz_stop
- first_rec
+ 1;
296 if (last_rec
- (first_rec
+ cur_pos
) + 1 >= blocks_per_page
) {
297 if ((last_rec
- blocks_per_page
+ 1) % blocks_per_page
!= 0)
298 d_stop
= last_rec
- ((last_rec
- blocks_per_page
+ 1) %
303 cur_pos
+= d_stop
- (first_rec
+ cur_pos
) + 1;
307 if (cur_pos
== 0 || first_rec
+ cur_pos
- 1 < last_rec
)
314 * This function builds a CCW request for block layer discard requests.
315 * Each page in the z/VM hypervisor that represents certain records of an FBA
316 * device will be padded with zeros. This is a special behaviour of the WRITE
317 * command which is triggered when no data payload is added to the CCW.
319 * Note: Due to issues in some z/VM versions, we can't fully utilise this
320 * special behaviour. We have to keep a 4k (or 8 block) alignment in mind to
321 * work around those issues and write actual zeroes to the unaligned parts in
322 * the request. This workaround might be removed in the future.
324 static struct dasd_ccw_req
*dasd_fba_build_cp_discard(
325 struct dasd_device
*memdev
,
326 struct dasd_block
*block
,
329 struct LO_fba_data
*LO_data
;
330 struct dasd_ccw_req
*cqr
;
333 sector_t wz_stop
= 0, d_stop
= 0;
334 sector_t first_rec
, last_rec
;
336 unsigned int blksize
= block
->bp_block
;
337 unsigned int blocks_per_page
;
340 int cur_pos
= 0; /* Current position within the extent */
346 first_rec
= blk_rq_pos(req
) >> block
->s2b_shift
;
348 (blk_rq_pos(req
) + blk_rq_sectors(req
) - 1) >> block
->s2b_shift
;
349 count
= last_rec
- first_rec
+ 1;
351 blocks_per_page
= BLOCKS_PER_PAGE(blksize
);
352 nr_ccws
= count_ccws(first_rec
, last_rec
, blocks_per_page
);
354 /* define extent + nr_ccws * locate record + nr_ccws * single CCW */
355 cplength
= 1 + 2 * nr_ccws
;
356 datasize
= sizeof(struct DE_fba_data
) +
357 nr_ccws
* (sizeof(struct LO_fba_data
) + sizeof(struct ccw1
));
359 cqr
= dasd_smalloc_request(DASD_FBA_MAGIC
, cplength
, datasize
, memdev
);
365 define_extent(ccw
++, cqr
->data
, WRITE
, blksize
, first_rec
, count
);
366 LO_data
= cqr
->data
+ sizeof(struct DE_fba_data
);
368 /* First part is not aligned. Calculate range to write zeroes. */
369 if (first_rec
% blocks_per_page
!= 0) {
370 wz_stop
= first_rec
+ blocks_per_page
-
371 (first_rec
% blocks_per_page
) - 1;
372 if (wz_stop
> last_rec
)
374 wz_count
= wz_stop
- first_rec
+ 1;
376 ccw
[-1].flags
|= CCW_FLAG_CC
;
377 locate_record(ccw
++, LO_data
++, WRITE
, cur_pos
, wz_count
);
379 ccw
[-1].flags
|= CCW_FLAG_CC
;
380 ccw_write_zero(ccw
++, wz_count
* blksize
);
385 /* We can do proper discard when we've got at least blocks_per_page blocks. */
386 if (last_rec
- (first_rec
+ cur_pos
) + 1 >= blocks_per_page
) {
387 /* is last record at page boundary? */
388 if ((last_rec
- blocks_per_page
+ 1) % blocks_per_page
!= 0)
389 d_stop
= last_rec
- ((last_rec
- blocks_per_page
+ 1) %
394 d_count
= d_stop
- (first_rec
+ cur_pos
) + 1;
396 ccw
[-1].flags
|= CCW_FLAG_CC
;
397 locate_record(ccw
++, LO_data
++, WRITE
, cur_pos
, d_count
);
399 ccw
[-1].flags
|= CCW_FLAG_CC
;
400 ccw_write_no_data(ccw
++);
405 /* We might still have some bits left which need to be zeroed. */
406 if (cur_pos
== 0 || first_rec
+ cur_pos
- 1 < last_rec
) {
408 wz_count
= last_rec
- d_stop
;
409 else if (wz_stop
!= 0)
410 wz_count
= last_rec
- wz_stop
;
414 ccw
[-1].flags
|= CCW_FLAG_CC
;
415 locate_record(ccw
++, LO_data
++, WRITE
, cur_pos
, wz_count
);
417 ccw
[-1].flags
|= CCW_FLAG_CC
;
418 ccw_write_zero(ccw
++, wz_count
* blksize
);
421 if (blk_noretry_request(req
) ||
422 block
->base
->features
& DASD_FEATURE_FAILFAST
)
423 set_bit(DASD_CQR_FLAGS_FAILFAST
, &cqr
->flags
);
425 cqr
->startdev
= memdev
;
426 cqr
->memdev
= memdev
;
428 cqr
->expires
= memdev
->default_expires
* HZ
; /* default 5 minutes */
429 cqr
->retries
= memdev
->default_retries
;
430 cqr
->buildclk
= get_tod_clock();
431 cqr
->status
= DASD_CQR_FILLED
;
436 static struct dasd_ccw_req
*dasd_fba_build_cp_regular(
437 struct dasd_device
*memdev
,
438 struct dasd_block
*block
,
441 struct dasd_fba_private
*private = block
->base
->private;
442 unsigned long *idaws
;
443 struct LO_fba_data
*LO_data
;
444 struct dasd_ccw_req
*cqr
;
446 struct req_iterator iter
;
449 int count
, cidaw
, cplength
, datasize
;
450 sector_t recid
, first_rec
, last_rec
;
451 unsigned int blksize
, off
;
454 if (rq_data_dir(req
) == READ
) {
455 cmd
= DASD_FBA_CCW_READ
;
456 } else if (rq_data_dir(req
) == WRITE
) {
457 cmd
= DASD_FBA_CCW_WRITE
;
459 return ERR_PTR(-EINVAL
);
460 blksize
= block
->bp_block
;
461 /* Calculate record id of first and last block. */
462 first_rec
= blk_rq_pos(req
) >> block
->s2b_shift
;
464 (blk_rq_pos(req
) + blk_rq_sectors(req
) - 1) >> block
->s2b_shift
;
465 /* Check struct bio and count the number of blocks for the request. */
468 rq_for_each_segment(bv
, req
, iter
) {
469 if (bv
.bv_len
& (blksize
- 1))
470 /* Fba can only do full blocks. */
471 return ERR_PTR(-EINVAL
);
472 count
+= bv
.bv_len
>> (block
->s2b_shift
+ 9);
473 if (idal_is_needed (page_address(bv
.bv_page
), bv
.bv_len
))
474 cidaw
+= bv
.bv_len
/ blksize
;
477 if (count
!= last_rec
- first_rec
+ 1)
478 return ERR_PTR(-EINVAL
);
479 /* 1x define extent + 1x locate record + number of blocks */
480 cplength
= 2 + count
;
481 /* 1x define extent + 1x locate record */
482 datasize
= sizeof(struct DE_fba_data
) + sizeof(struct LO_fba_data
) +
483 cidaw
* sizeof(unsigned long);
485 * Find out number of additional locate record ccws if the device
486 * can't do data chaining.
488 if (private->rdc_data
.mode
.bits
.data_chain
== 0) {
489 cplength
+= count
- 1;
490 datasize
+= (count
- 1)*sizeof(struct LO_fba_data
);
492 /* Allocate the ccw request. */
493 cqr
= dasd_smalloc_request(DASD_FBA_MAGIC
, cplength
, datasize
, memdev
);
497 /* First ccw is define extent. */
498 define_extent(ccw
++, cqr
->data
, rq_data_dir(req
),
499 block
->bp_block
, blk_rq_pos(req
), blk_rq_sectors(req
));
500 /* Build locate_record + read/write ccws. */
501 idaws
= (unsigned long *) (cqr
->data
+ sizeof(struct DE_fba_data
));
502 LO_data
= (struct LO_fba_data
*) (idaws
+ cidaw
);
503 /* Locate record for all blocks for smart devices. */
504 if (private->rdc_data
.mode
.bits
.data_chain
!= 0) {
505 ccw
[-1].flags
|= CCW_FLAG_CC
;
506 locate_record(ccw
++, LO_data
++, rq_data_dir(req
), 0, count
);
509 rq_for_each_segment(bv
, req
, iter
) {
510 dst
= page_address(bv
.bv_page
) + bv
.bv_offset
;
511 if (dasd_page_cache
) {
512 char *copy
= kmem_cache_alloc(dasd_page_cache
,
513 GFP_DMA
| __GFP_NOWARN
);
514 if (copy
&& rq_data_dir(req
) == WRITE
)
515 memcpy(copy
+ bv
.bv_offset
, dst
, bv
.bv_len
);
517 dst
= copy
+ bv
.bv_offset
;
519 for (off
= 0; off
< bv
.bv_len
; off
+= blksize
) {
520 /* Locate record for stupid devices. */
521 if (private->rdc_data
.mode
.bits
.data_chain
== 0) {
522 ccw
[-1].flags
|= CCW_FLAG_CC
;
523 locate_record(ccw
, LO_data
++,
525 recid
- first_rec
, 1);
526 ccw
->flags
= CCW_FLAG_CC
;
529 if (recid
> first_rec
)
530 ccw
[-1].flags
|= CCW_FLAG_DC
;
532 ccw
[-1].flags
|= CCW_FLAG_CC
;
535 ccw
->count
= block
->bp_block
;
536 if (idal_is_needed(dst
, blksize
)) {
537 ccw
->cda
= (__u32
)(addr_t
) idaws
;
538 ccw
->flags
= CCW_FLAG_IDA
;
539 idaws
= idal_create_words(idaws
, dst
, blksize
);
541 ccw
->cda
= (__u32
)(addr_t
) dst
;
549 if (blk_noretry_request(req
) ||
550 block
->base
->features
& DASD_FEATURE_FAILFAST
)
551 set_bit(DASD_CQR_FLAGS_FAILFAST
, &cqr
->flags
);
552 cqr
->startdev
= memdev
;
553 cqr
->memdev
= memdev
;
555 cqr
->expires
= memdev
->default_expires
* HZ
; /* default 5 minutes */
556 cqr
->retries
= memdev
->default_retries
;
557 cqr
->buildclk
= get_tod_clock();
558 cqr
->status
= DASD_CQR_FILLED
;
562 static struct dasd_ccw_req
*dasd_fba_build_cp(struct dasd_device
*memdev
,
563 struct dasd_block
*block
,
566 if (req_op(req
) == REQ_OP_DISCARD
|| req_op(req
) == REQ_OP_WRITE_ZEROES
)
567 return dasd_fba_build_cp_discard(memdev
, block
, req
);
569 return dasd_fba_build_cp_regular(memdev
, block
, req
);
573 dasd_fba_free_cp(struct dasd_ccw_req
*cqr
, struct request
*req
)
575 struct dasd_fba_private
*private = cqr
->block
->base
->private;
577 struct req_iterator iter
;
580 unsigned int blksize
, off
;
583 if (!dasd_page_cache
)
585 blksize
= cqr
->block
->bp_block
;
587 /* Skip over define extent & locate record. */
589 if (private->rdc_data
.mode
.bits
.data_chain
!= 0)
591 rq_for_each_segment(bv
, req
, iter
) {
592 dst
= page_address(bv
.bv_page
) + bv
.bv_offset
;
593 for (off
= 0; off
< bv
.bv_len
; off
+= blksize
) {
594 /* Skip locate record. */
595 if (private->rdc_data
.mode
.bits
.data_chain
== 0)
598 if (ccw
->flags
& CCW_FLAG_IDA
)
599 cda
= *((char **)((addr_t
) ccw
->cda
));
601 cda
= (char *)((addr_t
) ccw
->cda
);
603 if (rq_data_dir(req
) == READ
)
604 memcpy(dst
, cda
, bv
.bv_len
);
605 kmem_cache_free(dasd_page_cache
,
606 (void *)((addr_t
)cda
& PAGE_MASK
));
614 status
= cqr
->status
== DASD_CQR_DONE
;
615 dasd_sfree_request(cqr
, cqr
->memdev
);
619 static void dasd_fba_handle_terminated_request(struct dasd_ccw_req
*cqr
)
621 if (cqr
->retries
< 0)
622 cqr
->status
= DASD_CQR_FAILED
;
624 cqr
->status
= DASD_CQR_FILLED
;
628 dasd_fba_fill_info(struct dasd_device
* device
,
629 struct dasd_information2_t
* info
)
631 struct dasd_fba_private
*private = device
->private;
633 info
->label_block
= 1;
634 info
->FBA_layout
= 1;
635 info
->format
= DASD_FORMAT_LDL
;
636 info
->characteristics_size
= sizeof(private->rdc_data
);
637 memcpy(info
->characteristics
, &private->rdc_data
,
638 sizeof(private->rdc_data
));
639 info
->confdata_size
= 0;
644 dasd_fba_dump_sense_dbf(struct dasd_device
*device
, struct irb
*irb
,
649 sense
= (u64
*) dasd_get_sense(irb
);
651 DBF_DEV_EVENT(DBF_EMERG
, device
,
652 "%s: %s %02x%02x%02x %016llx %016llx %016llx "
654 scsw_is_tm(&irb
->scsw
) ? "t" : "c",
655 scsw_cc(&irb
->scsw
), scsw_cstat(&irb
->scsw
),
656 scsw_dstat(&irb
->scsw
), sense
[0], sense
[1],
659 DBF_DEV_EVENT(DBF_EMERG
, device
, "%s",
660 "SORRY - NO VALID SENSE AVAILABLE\n");
666 dasd_fba_dump_sense(struct dasd_device
*device
, struct dasd_ccw_req
* req
,
670 struct ccw1
*act
, *end
, *last
;
671 int len
, sl
, sct
, count
;
673 page
= (char *) get_zeroed_page(GFP_ATOMIC
);
675 DBF_DEV_EVENT(DBF_WARNING
, device
, "%s",
676 "No memory to dump sense data");
679 len
= sprintf(page
, PRINTK_HEADER
680 " I/O status report for device %s:\n",
681 dev_name(&device
->cdev
->dev
));
682 len
+= sprintf(page
+ len
, PRINTK_HEADER
683 " in req: %p CS: 0x%02X DS: 0x%02X\n", req
,
684 irb
->scsw
.cmd
.cstat
, irb
->scsw
.cmd
.dstat
);
685 len
+= sprintf(page
+ len
, PRINTK_HEADER
686 " device %s: Failing CCW: %p\n",
687 dev_name(&device
->cdev
->dev
),
688 (void *) (addr_t
) irb
->scsw
.cmd
.cpa
);
689 if (irb
->esw
.esw0
.erw
.cons
) {
690 for (sl
= 0; sl
< 4; sl
++) {
691 len
+= sprintf(page
+ len
, PRINTK_HEADER
692 " Sense(hex) %2d-%2d:",
693 (8 * sl
), ((8 * sl
) + 7));
695 for (sct
= 0; sct
< 8; sct
++) {
696 len
+= sprintf(page
+ len
, " %02x",
697 irb
->ecw
[8 * sl
+ sct
]);
699 len
+= sprintf(page
+ len
, "\n");
702 len
+= sprintf(page
+ len
, PRINTK_HEADER
703 " SORRY - NO VALID SENSE AVAILABLE\n");
705 printk(KERN_ERR
"%s", page
);
707 /* dump the Channel Program */
708 /* print first CCWs (maximum 8) */
710 for (last
= act
; last
->flags
& (CCW_FLAG_CC
| CCW_FLAG_DC
); last
++);
711 end
= min(act
+ 8, last
);
712 len
= sprintf(page
, PRINTK_HEADER
" Related CP in req: %p\n", req
);
714 len
+= sprintf(page
+ len
, PRINTK_HEADER
715 " CCW %p: %08X %08X DAT:",
716 act
, ((int *) act
)[0], ((int *) act
)[1]);
717 for (count
= 0; count
< 32 && count
< act
->count
;
718 count
+= sizeof(int))
719 len
+= sprintf(page
+ len
, " %08X",
720 ((int *) (addr_t
) act
->cda
)
722 len
+= sprintf(page
+ len
, "\n");
725 printk(KERN_ERR
"%s", page
);
728 /* print failing CCW area */
730 if (act
< ((struct ccw1
*)(addr_t
) irb
->scsw
.cmd
.cpa
) - 2) {
731 act
= ((struct ccw1
*)(addr_t
) irb
->scsw
.cmd
.cpa
) - 2;
732 len
+= sprintf(page
+ len
, PRINTK_HEADER
"......\n");
734 end
= min((struct ccw1
*)(addr_t
) irb
->scsw
.cmd
.cpa
+ 2, last
);
736 len
+= sprintf(page
+ len
, PRINTK_HEADER
737 " CCW %p: %08X %08X DAT:",
738 act
, ((int *) act
)[0], ((int *) act
)[1]);
739 for (count
= 0; count
< 32 && count
< act
->count
;
740 count
+= sizeof(int))
741 len
+= sprintf(page
+ len
, " %08X",
742 ((int *) (addr_t
) act
->cda
)
744 len
+= sprintf(page
+ len
, "\n");
748 /* print last CCWs */
749 if (act
< last
- 2) {
751 len
+= sprintf(page
+ len
, PRINTK_HEADER
"......\n");
753 while (act
<= last
) {
754 len
+= sprintf(page
+ len
, PRINTK_HEADER
755 " CCW %p: %08X %08X DAT:",
756 act
, ((int *) act
)[0], ((int *) act
)[1]);
757 for (count
= 0; count
< 32 && count
< act
->count
;
758 count
+= sizeof(int))
759 len
+= sprintf(page
+ len
, " %08X",
760 ((int *) (addr_t
) act
->cda
)
762 len
+= sprintf(page
+ len
, "\n");
766 printk(KERN_ERR
"%s", page
);
767 free_page((unsigned long) page
);
771 * max_blocks is dependent on the amount of storage that is available
772 * in the static io buffer for each device. Currently each device has
773 * 8192 bytes (=2 pages). For 64 bit one dasd_mchunkt_t structure has
774 * 24 bytes, the struct dasd_ccw_req has 136 bytes and each block can use
775 * up to 16 bytes (8 for the ccw and 8 for the idal pointer). In
776 * addition we have one define extent ccw + 16 bytes of data and a
777 * locate record ccw for each block (stupid devices!) + 16 bytes of data.
779 * (8192 - 24 - 136 - 8 - 16) / 40 = 200.2 blocks at maximum.
780 * We want to fit two into the available memory so that we can immediately
781 * start the next request if one finishes off. That makes 100.1 blocks
782 * for one request. Give a little safety and the result is 96.
784 static struct dasd_discipline dasd_fba_discipline
= {
785 .owner
= THIS_MODULE
,
789 .check_device
= dasd_fba_check_characteristics
,
790 .do_analysis
= dasd_fba_do_analysis
,
791 .verify_path
= dasd_generic_verify_path
,
792 .fill_geometry
= dasd_fba_fill_geometry
,
793 .start_IO
= dasd_start_IO
,
794 .term_IO
= dasd_term_IO
,
795 .handle_terminated_request
= dasd_fba_handle_terminated_request
,
796 .erp_action
= dasd_fba_erp_action
,
797 .erp_postaction
= dasd_fba_erp_postaction
,
798 .check_for_device_change
= dasd_fba_check_for_device_change
,
799 .build_cp
= dasd_fba_build_cp
,
800 .free_cp
= dasd_fba_free_cp
,
801 .dump_sense
= dasd_fba_dump_sense
,
802 .dump_sense_dbf
= dasd_fba_dump_sense_dbf
,
803 .fill_info
= dasd_fba_fill_info
,
811 ASCEBC(dasd_fba_discipline
.ebcname
, 4);
812 ret
= ccw_driver_register(&dasd_fba_driver
);
814 wait_for_device_probe();
820 dasd_fba_cleanup(void)
822 ccw_driver_unregister(&dasd_fba_driver
);
825 module_init(dasd_fba_init
);
826 module_exit(dasd_fba_cleanup
);