Commit | Line | Data |
---|---|---|
138c014d | 1 | /* |
1da177e4 LT |
2 | * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com> |
3 | * Bugreports.to..: <Linux390@de.ibm.com> | |
d41dd122 | 4 | * Copyright IBM Corp. 1999, 2009 |
1da177e4 LT |
5 | */ |
6 | ||
ca99dab0 | 7 | #define KMSG_COMPONENT "dasd-fba" |
fc19f381 | 8 | |
1da177e4 LT |
9 | #include <linux/stddef.h> |
10 | #include <linux/kernel.h> | |
11 | #include <asm/debug.h> | |
12 | ||
13 | #include <linux/slab.h> | |
14 | #include <linux/hdreg.h> /* HDIO_GETGEO */ | |
15 | #include <linux/bio.h> | |
16 | #include <linux/module.h> | |
17 | #include <linux/init.h> | |
18 | ||
19 | #include <asm/idals.h> | |
20 | #include <asm/ebcdic.h> | |
21 | #include <asm/io.h> | |
1da177e4 LT |
22 | #include <asm/ccwdev.h> |
23 | ||
24 | #include "dasd_int.h" | |
25 | #include "dasd_fba.h" | |
26 | ||
27 | #ifdef PRINTK_HEADER | |
28 | #undef PRINTK_HEADER | |
29 | #endif /* PRINTK_HEADER */ | |
30 | #define PRINTK_HEADER "dasd(fba):" | |
31 | ||
32 | #define DASD_FBA_CCW_WRITE 0x41 | |
33 | #define DASD_FBA_CCW_READ 0x42 | |
34 | #define DASD_FBA_CCW_LOCATE 0x43 | |
35 | #define DASD_FBA_CCW_DEFINE_EXTENT 0x63 | |
36 | ||
37 | MODULE_LICENSE("GPL"); | |
38 | ||
39 | static struct dasd_discipline dasd_fba_discipline; | |
40 | ||
41 | struct dasd_fba_private { | |
42 | struct dasd_fba_characteristics rdc_data; | |
43 | }; | |
44 | ||
45 | static struct ccw_device_id dasd_fba_ids[] = { | |
d2c993d8 HC |
46 | { CCW_DEVICE_DEVTYPE (0x6310, 0, 0x9336, 0), .driver_info = 0x1}, |
47 | { CCW_DEVICE_DEVTYPE (0x3880, 0, 0x3370, 0), .driver_info = 0x2}, | |
1da177e4 LT |
48 | { /* end of list */ }, |
49 | }; | |
50 | ||
51 | MODULE_DEVICE_TABLE(ccw, dasd_fba_ids); | |
52 | ||
53 | static struct ccw_driver dasd_fba_driver; /* see below */ | |
54 | static int | |
55 | dasd_fba_probe(struct ccw_device *cdev) | |
56 | { | |
40545573 | 57 | return dasd_generic_probe(cdev, &dasd_fba_discipline); |
1da177e4 LT |
58 | } |
59 | ||
60 | static int | |
61 | dasd_fba_set_online(struct ccw_device *cdev) | |
62 | { | |
40545573 | 63 | return dasd_generic_set_online(cdev, &dasd_fba_discipline); |
1da177e4 LT |
64 | } |
65 | ||
66 | static struct ccw_driver dasd_fba_driver = { | |
3bda058b SO |
67 | .driver = { |
68 | .name = "dasd-fba", | |
69 | .owner = THIS_MODULE, | |
70 | }, | |
1da177e4 LT |
71 | .ids = dasd_fba_ids, |
72 | .probe = dasd_fba_probe, | |
73 | .remove = dasd_generic_remove, | |
74 | .set_offline = dasd_generic_set_offline, | |
75 | .set_online = dasd_fba_set_online, | |
76 | .notify = dasd_generic_notify, | |
a4d26c6a | 77 | .path_event = dasd_generic_path_event, |
d41dd122 SH |
78 | .freeze = dasd_generic_pm_freeze, |
79 | .thaw = dasd_generic_restore_device, | |
80 | .restore = dasd_generic_restore_device, | |
420f42ec | 81 | .int_class = IRQIO_DAS, |
1da177e4 LT |
82 | }; |
83 | ||
4d284cac | 84 | static void |
1da177e4 LT |
85 | define_extent(struct ccw1 * ccw, struct DE_fba_data *data, int rw, |
86 | int blksize, int beg, int nr) | |
87 | { | |
88 | ccw->cmd_code = DASD_FBA_CCW_DEFINE_EXTENT; | |
89 | ccw->flags = 0; | |
90 | ccw->count = 16; | |
91 | ccw->cda = (__u32) __pa(data); | |
92 | memset(data, 0, sizeof (struct DE_fba_data)); | |
93 | if (rw == WRITE) | |
94 | (data->mask).perm = 0x0; | |
95 | else if (rw == READ) | |
96 | (data->mask).perm = 0x1; | |
97 | else | |
98 | data->mask.perm = 0x2; | |
99 | data->blk_size = blksize; | |
100 | data->ext_loc = beg; | |
101 | data->ext_end = nr - 1; | |
102 | } | |
103 | ||
4d284cac | 104 | static void |
1da177e4 LT |
105 | locate_record(struct ccw1 * ccw, struct LO_fba_data *data, int rw, |
106 | int block_nr, int block_ct) | |
107 | { | |
108 | ccw->cmd_code = DASD_FBA_CCW_LOCATE; | |
109 | ccw->flags = 0; | |
110 | ccw->count = 8; | |
111 | ccw->cda = (__u32) __pa(data); | |
112 | memset(data, 0, sizeof (struct LO_fba_data)); | |
113 | if (rw == WRITE) | |
114 | data->operation.cmd = 0x5; | |
115 | else if (rw == READ) | |
116 | data->operation.cmd = 0x6; | |
117 | else | |
118 | data->operation.cmd = 0x8; | |
119 | data->blk_nr = block_nr; | |
120 | data->blk_ct = block_ct; | |
121 | } | |
122 | ||
123 | static int | |
124 | dasd_fba_check_characteristics(struct dasd_device *device) | |
125 | { | |
8e09f215 | 126 | struct dasd_block *block; |
1da177e4 | 127 | struct dasd_fba_private *private; |
138c014d | 128 | struct ccw_device *cdev = device->cdev; |
1da177e4 | 129 | int rc; |
33b62a30 | 130 | int readonly; |
1da177e4 LT |
131 | |
132 | private = (struct dasd_fba_private *) device->private; | |
92636b15 SO |
133 | if (!private) { |
134 | private = kzalloc(sizeof(*private), GFP_KERNEL | GFP_DMA); | |
135 | if (!private) { | |
fc19f381 SH |
136 | dev_warn(&device->cdev->dev, |
137 | "Allocating memory for private DASD " | |
138 | "data failed\n"); | |
1da177e4 LT |
139 | return -ENOMEM; |
140 | } | |
141 | device->private = (void *) private; | |
92636b15 SO |
142 | } else { |
143 | memset(private, 0, sizeof(*private)); | |
1da177e4 | 144 | } |
8e09f215 SW |
145 | block = dasd_alloc_block(); |
146 | if (IS_ERR(block)) { | |
b8ed5dd5 SH |
147 | DBF_EVENT_DEVID(DBF_WARNING, cdev, "%s", "could not allocate " |
148 | "dasd block structure"); | |
7337194f CH |
149 | device->private = NULL; |
150 | kfree(private); | |
8e09f215 SW |
151 | return PTR_ERR(block); |
152 | } | |
153 | device->block = block; | |
154 | block->base = device; | |
155 | ||
1da177e4 | 156 | /* Read Device Characteristics */ |
68b781fe SH |
157 | rc = dasd_generic_read_dev_chars(device, DASD_FBA_MAGIC, |
158 | &private->rdc_data, 32); | |
1da177e4 | 159 | if (rc) { |
b8ed5dd5 SH |
160 | DBF_EVENT_DEVID(DBF_WARNING, cdev, "Read device " |
161 | "characteristics returned error %d", rc); | |
7337194f CH |
162 | device->block = NULL; |
163 | dasd_free_block(block); | |
164 | device->private = NULL; | |
165 | kfree(private); | |
1da177e4 LT |
166 | return rc; |
167 | } | |
168 | ||
7c8faa86 | 169 | device->default_expires = DASD_EXPIRES; |
a4d26c6a | 170 | device->path_data.opm = LPM_ANYPATH; |
7c8faa86 | 171 | |
33b62a30 SW |
172 | readonly = dasd_device_is_ro(device); |
173 | if (readonly) | |
174 | set_bit(DASD_FLAG_DEVICE_RO, &device->flags); | |
175 | ||
fc19f381 SH |
176 | dev_info(&device->cdev->dev, |
177 | "New FBA DASD %04X/%02X (CU %04X/%02X) with %d MB " | |
33b62a30 | 178 | "and %d B/blk%s\n", |
fc19f381 SH |
179 | cdev->id.dev_type, |
180 | cdev->id.dev_model, | |
181 | cdev->id.cu_type, | |
182 | cdev->id.cu_model, | |
183 | ((private->rdc_data.blk_bdsa * | |
184 | (private->rdc_data.blk_size >> 9)) >> 11), | |
33b62a30 SW |
185 | private->rdc_data.blk_size, |
186 | readonly ? ", read-only device" : ""); | |
1da177e4 LT |
187 | return 0; |
188 | } | |
189 | ||
8e09f215 | 190 | static int dasd_fba_do_analysis(struct dasd_block *block) |
1da177e4 LT |
191 | { |
192 | struct dasd_fba_private *private; | |
193 | int sb, rc; | |
194 | ||
8e09f215 | 195 | private = (struct dasd_fba_private *) block->base->private; |
1da177e4 LT |
196 | rc = dasd_check_blocksize(private->rdc_data.blk_size); |
197 | if (rc) { | |
fc19f381 | 198 | DBF_DEV_EVENT(DBF_WARNING, block->base, "unknown blocksize %d", |
1da177e4 LT |
199 | private->rdc_data.blk_size); |
200 | return rc; | |
201 | } | |
8e09f215 SW |
202 | block->blocks = private->rdc_data.blk_bdsa; |
203 | block->bp_block = private->rdc_data.blk_size; | |
204 | block->s2b_shift = 0; /* bits to shift 512 to get a block */ | |
1da177e4 | 205 | for (sb = 512; sb < private->rdc_data.blk_size; sb = sb << 1) |
8e09f215 | 206 | block->s2b_shift++; |
1da177e4 LT |
207 | return 0; |
208 | } | |
209 | ||
8e09f215 SW |
210 | static int dasd_fba_fill_geometry(struct dasd_block *block, |
211 | struct hd_geometry *geo) | |
1da177e4 | 212 | { |
8e09f215 | 213 | if (dasd_check_blocksize(block->bp_block) != 0) |
1da177e4 | 214 | return -EINVAL; |
8e09f215 | 215 | geo->cylinders = (block->blocks << block->s2b_shift) >> 10; |
1da177e4 | 216 | geo->heads = 16; |
8e09f215 | 217 | geo->sectors = 128 >> block->s2b_shift; |
1da177e4 LT |
218 | return 0; |
219 | } | |
220 | ||
1da177e4 LT |
221 | static dasd_erp_fn_t |
222 | dasd_fba_erp_action(struct dasd_ccw_req * cqr) | |
223 | { | |
224 | return dasd_default_erp_action; | |
225 | } | |
226 | ||
227 | static dasd_erp_fn_t | |
228 | dasd_fba_erp_postaction(struct dasd_ccw_req * cqr) | |
229 | { | |
230 | if (cqr->function == dasd_default_erp_action) | |
231 | return dasd_default_erp_postaction; | |
232 | ||
fc19f381 | 233 | DBF_DEV_EVENT(DBF_WARNING, cqr->startdev, "unknown ERP action %p", |
1da177e4 LT |
234 | cqr->function); |
235 | return NULL; | |
236 | } | |
237 | ||
5a27e60d SW |
238 | static void dasd_fba_check_for_device_change(struct dasd_device *device, |
239 | struct dasd_ccw_req *cqr, | |
240 | struct irb *irb) | |
8e09f215 SW |
241 | { |
242 | char mask; | |
243 | ||
244 | /* first of all check for state change pending interrupt */ | |
245 | mask = DEV_STAT_ATTENTION | DEV_STAT_DEV_END | DEV_STAT_UNIT_EXCEP; | |
5a27e60d | 246 | if ((irb->scsw.cmd.dstat & mask) == mask) |
8e09f215 | 247 | dasd_generic_handle_state_change(device); |
8e09f215 SW |
248 | }; |
249 | ||
250 | static struct dasd_ccw_req *dasd_fba_build_cp(struct dasd_device * memdev, | |
251 | struct dasd_block *block, | |
252 | struct request *req) | |
1da177e4 LT |
253 | { |
254 | struct dasd_fba_private *private; | |
255 | unsigned long *idaws; | |
256 | struct LO_fba_data *LO_data; | |
257 | struct dasd_ccw_req *cqr; | |
258 | struct ccw1 *ccw; | |
5705f702 | 259 | struct req_iterator iter; |
1da177e4 LT |
260 | struct bio_vec *bv; |
261 | char *dst; | |
262 | int count, cidaw, cplength, datasize; | |
263 | sector_t recid, first_rec, last_rec; | |
264 | unsigned int blksize, off; | |
265 | unsigned char cmd; | |
1da177e4 | 266 | |
8e09f215 | 267 | private = (struct dasd_fba_private *) block->base->private; |
1da177e4 LT |
268 | if (rq_data_dir(req) == READ) { |
269 | cmd = DASD_FBA_CCW_READ; | |
270 | } else if (rq_data_dir(req) == WRITE) { | |
271 | cmd = DASD_FBA_CCW_WRITE; | |
272 | } else | |
273 | return ERR_PTR(-EINVAL); | |
8e09f215 | 274 | blksize = block->bp_block; |
1da177e4 | 275 | /* Calculate record id of first and last block. */ |
83096ebf TH |
276 | first_rec = blk_rq_pos(req) >> block->s2b_shift; |
277 | last_rec = | |
278 | (blk_rq_pos(req) + blk_rq_sectors(req) - 1) >> block->s2b_shift; | |
1da177e4 LT |
279 | /* Check struct bio and count the number of blocks for the request. */ |
280 | count = 0; | |
281 | cidaw = 0; | |
5705f702 | 282 | rq_for_each_segment(bv, req, iter) { |
6c92e699 JA |
283 | if (bv->bv_len & (blksize - 1)) |
284 | /* Fba can only do full blocks. */ | |
285 | return ERR_PTR(-EINVAL); | |
8e09f215 | 286 | count += bv->bv_len >> (block->s2b_shift + 9); |
347a8dc3 | 287 | #if defined(CONFIG_64BIT) |
6c92e699 JA |
288 | if (idal_is_needed (page_address(bv->bv_page), bv->bv_len)) |
289 | cidaw += bv->bv_len / blksize; | |
1da177e4 | 290 | #endif |
1da177e4 LT |
291 | } |
292 | /* Paranoia. */ | |
293 | if (count != last_rec - first_rec + 1) | |
294 | return ERR_PTR(-EINVAL); | |
295 | /* 1x define extent + 1x locate record + number of blocks */ | |
296 | cplength = 2 + count; | |
297 | /* 1x define extent + 1x locate record */ | |
298 | datasize = sizeof(struct DE_fba_data) + sizeof(struct LO_fba_data) + | |
299 | cidaw * sizeof(unsigned long); | |
300 | /* | |
301 | * Find out number of additional locate record ccws if the device | |
302 | * can't do data chaining. | |
303 | */ | |
304 | if (private->rdc_data.mode.bits.data_chain == 0) { | |
305 | cplength += count - 1; | |
306 | datasize += (count - 1)*sizeof(struct LO_fba_data); | |
307 | } | |
308 | /* Allocate the ccw request. */ | |
68b781fe | 309 | cqr = dasd_smalloc_request(DASD_FBA_MAGIC, cplength, datasize, memdev); |
1da177e4 LT |
310 | if (IS_ERR(cqr)) |
311 | return cqr; | |
312 | ccw = cqr->cpaddr; | |
313 | /* First ccw is define extent. */ | |
314 | define_extent(ccw++, cqr->data, rq_data_dir(req), | |
83096ebf | 315 | block->bp_block, blk_rq_pos(req), blk_rq_sectors(req)); |
1da177e4 LT |
316 | /* Build locate_record + read/write ccws. */ |
317 | idaws = (unsigned long *) (cqr->data + sizeof(struct DE_fba_data)); | |
318 | LO_data = (struct LO_fba_data *) (idaws + cidaw); | |
319 | /* Locate record for all blocks for smart devices. */ | |
320 | if (private->rdc_data.mode.bits.data_chain != 0) { | |
321 | ccw[-1].flags |= CCW_FLAG_CC; | |
322 | locate_record(ccw++, LO_data++, rq_data_dir(req), 0, count); | |
323 | } | |
324 | recid = first_rec; | |
5705f702 | 325 | rq_for_each_segment(bv, req, iter) { |
1da177e4 LT |
326 | dst = page_address(bv->bv_page) + bv->bv_offset; |
327 | if (dasd_page_cache) { | |
328 | char *copy = kmem_cache_alloc(dasd_page_cache, | |
441e143e | 329 | GFP_DMA | __GFP_NOWARN); |
1da177e4 LT |
330 | if (copy && rq_data_dir(req) == WRITE) |
331 | memcpy(copy + bv->bv_offset, dst, bv->bv_len); | |
332 | if (copy) | |
333 | dst = copy + bv->bv_offset; | |
334 | } | |
335 | for (off = 0; off < bv->bv_len; off += blksize) { | |
336 | /* Locate record for stupid devices. */ | |
337 | if (private->rdc_data.mode.bits.data_chain == 0) { | |
338 | ccw[-1].flags |= CCW_FLAG_CC; | |
339 | locate_record(ccw, LO_data++, | |
340 | rq_data_dir(req), | |
341 | recid - first_rec, 1); | |
342 | ccw->flags = CCW_FLAG_CC; | |
343 | ccw++; | |
344 | } else { | |
345 | if (recid > first_rec) | |
346 | ccw[-1].flags |= CCW_FLAG_DC; | |
347 | else | |
348 | ccw[-1].flags |= CCW_FLAG_CC; | |
349 | } | |
350 | ccw->cmd_code = cmd; | |
8e09f215 | 351 | ccw->count = block->bp_block; |
1da177e4 LT |
352 | if (idal_is_needed(dst, blksize)) { |
353 | ccw->cda = (__u32)(addr_t) idaws; | |
354 | ccw->flags = CCW_FLAG_IDA; | |
355 | idaws = idal_create_words(idaws, dst, blksize); | |
356 | } else { | |
357 | ccw->cda = (__u32)(addr_t) dst; | |
358 | ccw->flags = 0; | |
359 | } | |
360 | ccw++; | |
361 | dst += blksize; | |
362 | recid++; | |
363 | } | |
364 | } | |
13de227b HS |
365 | if (blk_noretry_request(req) || |
366 | block->base->features & DASD_FEATURE_FAILFAST) | |
1c01b8a5 | 367 | set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags); |
8e09f215 SW |
368 | cqr->startdev = memdev; |
369 | cqr->memdev = memdev; | |
370 | cqr->block = block; | |
7c8faa86 | 371 | cqr->expires = memdev->default_expires * HZ; /* default 5 minutes */ |
d61f6f3d HH |
372 | cqr->retries = 32; |
373 | cqr->buildclk = get_clock(); | |
1da177e4 LT |
374 | cqr->status = DASD_CQR_FILLED; |
375 | return cqr; | |
376 | } | |
377 | ||
378 | static int | |
379 | dasd_fba_free_cp(struct dasd_ccw_req *cqr, struct request *req) | |
380 | { | |
381 | struct dasd_fba_private *private; | |
382 | struct ccw1 *ccw; | |
5705f702 | 383 | struct req_iterator iter; |
1da177e4 LT |
384 | struct bio_vec *bv; |
385 | char *dst, *cda; | |
386 | unsigned int blksize, off; | |
5705f702 | 387 | int status; |
1da177e4 LT |
388 | |
389 | if (!dasd_page_cache) | |
390 | goto out; | |
8e09f215 SW |
391 | private = (struct dasd_fba_private *) cqr->block->base->private; |
392 | blksize = cqr->block->bp_block; | |
1da177e4 LT |
393 | ccw = cqr->cpaddr; |
394 | /* Skip over define extent & locate record. */ | |
395 | ccw++; | |
396 | if (private->rdc_data.mode.bits.data_chain != 0) | |
397 | ccw++; | |
5705f702 | 398 | rq_for_each_segment(bv, req, iter) { |
1da177e4 LT |
399 | dst = page_address(bv->bv_page) + bv->bv_offset; |
400 | for (off = 0; off < bv->bv_len; off += blksize) { | |
401 | /* Skip locate record. */ | |
402 | if (private->rdc_data.mode.bits.data_chain == 0) | |
403 | ccw++; | |
404 | if (dst) { | |
405 | if (ccw->flags & CCW_FLAG_IDA) | |
406 | cda = *((char **)((addr_t) ccw->cda)); | |
407 | else | |
408 | cda = (char *)((addr_t) ccw->cda); | |
409 | if (dst != cda) { | |
410 | if (rq_data_dir(req) == READ) | |
411 | memcpy(dst, cda, bv->bv_len); | |
412 | kmem_cache_free(dasd_page_cache, | |
413 | (void *)((addr_t)cda & PAGE_MASK)); | |
414 | } | |
415 | dst = NULL; | |
416 | } | |
417 | ccw++; | |
418 | } | |
419 | } | |
420 | out: | |
421 | status = cqr->status == DASD_CQR_DONE; | |
8e09f215 | 422 | dasd_sfree_request(cqr, cqr->memdev); |
1da177e4 LT |
423 | return status; |
424 | } | |
425 | ||
8e09f215 SW |
426 | static void dasd_fba_handle_terminated_request(struct dasd_ccw_req *cqr) |
427 | { | |
428 | cqr->status = DASD_CQR_FILLED; | |
429 | }; | |
430 | ||
1da177e4 LT |
431 | static int |
432 | dasd_fba_fill_info(struct dasd_device * device, | |
433 | struct dasd_information2_t * info) | |
434 | { | |
435 | info->label_block = 1; | |
436 | info->FBA_layout = 1; | |
437 | info->format = DASD_FORMAT_LDL; | |
438 | info->characteristics_size = sizeof(struct dasd_fba_characteristics); | |
439 | memcpy(info->characteristics, | |
440 | &((struct dasd_fba_private *) device->private)->rdc_data, | |
441 | sizeof (struct dasd_fba_characteristics)); | |
442 | info->confdata_size = 0; | |
443 | return 0; | |
444 | } | |
445 | ||
fc19f381 | 446 | static void |
aeec92ca SH |
447 | dasd_fba_dump_sense_dbf(struct dasd_device *device, struct irb *irb, |
448 | char *reason) | |
fc19f381 | 449 | { |
aeec92ca SH |
450 | u64 *sense; |
451 | ||
452 | sense = (u64 *) dasd_get_sense(irb); | |
453 | if (sense) { | |
454 | DBF_DEV_EVENT(DBF_EMERG, device, | |
455 | "%s: %s %02x%02x%02x %016llx %016llx %016llx " | |
456 | "%016llx", reason, | |
457 | scsw_is_tm(&irb->scsw) ? "t" : "c", | |
458 | scsw_cc(&irb->scsw), scsw_cstat(&irb->scsw), | |
459 | scsw_dstat(&irb->scsw), sense[0], sense[1], | |
460 | sense[2], sense[3]); | |
fc19f381 SH |
461 | } else { |
462 | DBF_DEV_EVENT(DBF_EMERG, device, "%s", | |
463 | "SORRY - NO VALID SENSE AVAILABLE\n"); | |
464 | } | |
465 | } | |
466 | ||
467 | ||
1da177e4 LT |
468 | static void |
469 | dasd_fba_dump_sense(struct dasd_device *device, struct dasd_ccw_req * req, | |
470 | struct irb *irb) | |
471 | { | |
472 | char *page; | |
473 | struct ccw1 *act, *end, *last; | |
474 | int len, sl, sct, count; | |
475 | ||
476 | page = (char *) get_zeroed_page(GFP_ATOMIC); | |
477 | if (page == NULL) { | |
fc19f381 | 478 | DBF_DEV_EVENT(DBF_WARNING, device, "%s", |
1da177e4 LT |
479 | "No memory to dump sense data"); |
480 | return; | |
481 | } | |
773bab4a | 482 | len = sprintf(page, PRINTK_HEADER |
1da177e4 | 483 | " I/O status report for device %s:\n", |
2a0217d5 | 484 | dev_name(&device->cdev->dev)); |
773bab4a | 485 | len += sprintf(page + len, PRINTK_HEADER |
1da177e4 | 486 | " in req: %p CS: 0x%02X DS: 0x%02X\n", req, |
23d805b6 | 487 | irb->scsw.cmd.cstat, irb->scsw.cmd.dstat); |
773bab4a | 488 | len += sprintf(page + len, PRINTK_HEADER |
1da177e4 | 489 | " device %s: Failing CCW: %p\n", |
2a0217d5 | 490 | dev_name(&device->cdev->dev), |
23d805b6 | 491 | (void *) (addr_t) irb->scsw.cmd.cpa); |
1da177e4 LT |
492 | if (irb->esw.esw0.erw.cons) { |
493 | for (sl = 0; sl < 4; sl++) { | |
773bab4a | 494 | len += sprintf(page + len, PRINTK_HEADER |
1da177e4 LT |
495 | " Sense(hex) %2d-%2d:", |
496 | (8 * sl), ((8 * sl) + 7)); | |
497 | ||
498 | for (sct = 0; sct < 8; sct++) { | |
499 | len += sprintf(page + len, " %02x", | |
500 | irb->ecw[8 * sl + sct]); | |
501 | } | |
502 | len += sprintf(page + len, "\n"); | |
503 | } | |
504 | } else { | |
773bab4a | 505 | len += sprintf(page + len, PRINTK_HEADER |
1da177e4 LT |
506 | " SORRY - NO VALID SENSE AVAILABLE\n"); |
507 | } | |
fc19f381 | 508 | printk(KERN_ERR "%s", page); |
1da177e4 LT |
509 | |
510 | /* dump the Channel Program */ | |
511 | /* print first CCWs (maximum 8) */ | |
512 | act = req->cpaddr; | |
513 | for (last = act; last->flags & (CCW_FLAG_CC | CCW_FLAG_DC); last++); | |
514 | end = min(act + 8, last); | |
773bab4a | 515 | len = sprintf(page, PRINTK_HEADER " Related CP in req: %p\n", req); |
1da177e4 | 516 | while (act <= end) { |
773bab4a | 517 | len += sprintf(page + len, PRINTK_HEADER |
1da177e4 LT |
518 | " CCW %p: %08X %08X DAT:", |
519 | act, ((int *) act)[0], ((int *) act)[1]); | |
520 | for (count = 0; count < 32 && count < act->count; | |
521 | count += sizeof(int)) | |
522 | len += sprintf(page + len, " %08X", | |
523 | ((int *) (addr_t) act->cda) | |
524 | [(count>>2)]); | |
525 | len += sprintf(page + len, "\n"); | |
526 | act++; | |
527 | } | |
fc19f381 | 528 | printk(KERN_ERR "%s", page); |
1da177e4 LT |
529 | |
530 | ||
531 | /* print failing CCW area */ | |
532 | len = 0; | |
23d805b6 PO |
533 | if (act < ((struct ccw1 *)(addr_t) irb->scsw.cmd.cpa) - 2) { |
534 | act = ((struct ccw1 *)(addr_t) irb->scsw.cmd.cpa) - 2; | |
773bab4a | 535 | len += sprintf(page + len, PRINTK_HEADER "......\n"); |
1da177e4 | 536 | } |
23d805b6 | 537 | end = min((struct ccw1 *)(addr_t) irb->scsw.cmd.cpa + 2, last); |
1da177e4 | 538 | while (act <= end) { |
773bab4a | 539 | len += sprintf(page + len, PRINTK_HEADER |
1da177e4 LT |
540 | " CCW %p: %08X %08X DAT:", |
541 | act, ((int *) act)[0], ((int *) act)[1]); | |
542 | for (count = 0; count < 32 && count < act->count; | |
543 | count += sizeof(int)) | |
544 | len += sprintf(page + len, " %08X", | |
545 | ((int *) (addr_t) act->cda) | |
546 | [(count>>2)]); | |
547 | len += sprintf(page + len, "\n"); | |
548 | act++; | |
549 | } | |
550 | ||
551 | /* print last CCWs */ | |
552 | if (act < last - 2) { | |
553 | act = last - 2; | |
773bab4a | 554 | len += sprintf(page + len, PRINTK_HEADER "......\n"); |
1da177e4 LT |
555 | } |
556 | while (act <= last) { | |
773bab4a | 557 | len += sprintf(page + len, PRINTK_HEADER |
1da177e4 LT |
558 | " CCW %p: %08X %08X DAT:", |
559 | act, ((int *) act)[0], ((int *) act)[1]); | |
560 | for (count = 0; count < 32 && count < act->count; | |
561 | count += sizeof(int)) | |
562 | len += sprintf(page + len, " %08X", | |
563 | ((int *) (addr_t) act->cda) | |
564 | [(count>>2)]); | |
565 | len += sprintf(page + len, "\n"); | |
566 | act++; | |
567 | } | |
568 | if (len > 0) | |
fc19f381 | 569 | printk(KERN_ERR "%s", page); |
1da177e4 LT |
570 | free_page((unsigned long) page); |
571 | } | |
572 | ||
573 | /* | |
574 | * max_blocks is dependent on the amount of storage that is available | |
575 | * in the static io buffer for each device. Currently each device has | |
576 | * 8192 bytes (=2 pages). For 64 bit one dasd_mchunkt_t structure has | |
577 | * 24 bytes, the struct dasd_ccw_req has 136 bytes and each block can use | |
578 | * up to 16 bytes (8 for the ccw and 8 for the idal pointer). In | |
138c014d | 579 | * addition we have one define extent ccw + 16 bytes of data and a |
1da177e4 LT |
580 | * locate record ccw for each block (stupid devices!) + 16 bytes of data. |
581 | * That makes: | |
582 | * (8192 - 24 - 136 - 8 - 16) / 40 = 200.2 blocks at maximum. | |
583 | * We want to fit two into the available memory so that we can immediately | |
584 | * start the next request if one finishes off. That makes 100.1 blocks | |
585 | * for one request. Give a little safety and the result is 96. | |
586 | */ | |
587 | static struct dasd_discipline dasd_fba_discipline = { | |
588 | .owner = THIS_MODULE, | |
589 | .name = "FBA ", | |
590 | .ebcname = "FBA ", | |
591 | .max_blocks = 96, | |
592 | .check_device = dasd_fba_check_characteristics, | |
593 | .do_analysis = dasd_fba_do_analysis, | |
a4d26c6a | 594 | .verify_path = dasd_generic_verify_path, |
1da177e4 LT |
595 | .fill_geometry = dasd_fba_fill_geometry, |
596 | .start_IO = dasd_start_IO, | |
597 | .term_IO = dasd_term_IO, | |
8e09f215 | 598 | .handle_terminated_request = dasd_fba_handle_terminated_request, |
1da177e4 LT |
599 | .erp_action = dasd_fba_erp_action, |
600 | .erp_postaction = dasd_fba_erp_postaction, | |
5a27e60d | 601 | .check_for_device_change = dasd_fba_check_for_device_change, |
1da177e4 LT |
602 | .build_cp = dasd_fba_build_cp, |
603 | .free_cp = dasd_fba_free_cp, | |
604 | .dump_sense = dasd_fba_dump_sense, | |
fc19f381 | 605 | .dump_sense_dbf = dasd_fba_dump_sense_dbf, |
1da177e4 LT |
606 | .fill_info = dasd_fba_fill_info, |
607 | }; | |
608 | ||
609 | static int __init | |
610 | dasd_fba_init(void) | |
611 | { | |
736e6ea0 SO |
612 | int ret; |
613 | ||
1da177e4 | 614 | ASCEBC(dasd_fba_discipline.ebcname, 4); |
736e6ea0 SO |
615 | ret = ccw_driver_register(&dasd_fba_driver); |
616 | if (!ret) | |
617 | wait_for_device_probe(); | |
618 | ||
619 | return ret; | |
1da177e4 LT |
620 | } |
621 | ||
622 | static void __exit | |
623 | dasd_fba_cleanup(void) | |
624 | { | |
625 | ccw_driver_unregister(&dasd_fba_driver); | |
626 | } | |
627 | ||
628 | module_init(dasd_fba_init); | |
629 | module_exit(dasd_fba_cleanup); |