dasd_diag.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. /*
  2. * File...........: linux/drivers/s390/block/dasd_diag.c
  3. * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
  4. * Based on.......: linux/drivers/s390/block/mdisk.c
  5. * ...............: by Hartmunt Penner <hpenner@de.ibm.com>
  6. * Bugreports.to..: <Linux390@de.ibm.com>
  7. * (C) IBM Corporation, IBM Deutschland Entwicklung GmbH, 1999,2000
  8. *
  9. */
  10. #define KMSG_COMPONENT "dasd"
  11. #include <linux/kernel_stat.h>
  12. #include <linux/stddef.h>
  13. #include <linux/kernel.h>
  14. #include <linux/slab.h>
  15. #include <linux/hdreg.h>
  16. #include <linux/bio.h>
  17. #include <linux/module.h>
  18. #include <linux/init.h>
  19. #include <linux/jiffies.h>
  20. #include <asm/dasd.h>
  21. #include <asm/debug.h>
  22. #include <asm/ebcdic.h>
  23. #include <asm/io.h>
  24. #include <asm/irq.h>
  25. #include <asm/vtoc.h>
  26. #include <asm/diag.h>
  27. #include "dasd_int.h"
  28. #include "dasd_diag.h"
  29. #define PRINTK_HEADER "dasd(diag):"
  30. MODULE_LICENSE("GPL");
  31. /* The maximum number of blocks per request (max_blocks) is dependent on the
  32. * amount of storage that is available in the static I/O buffer for each
  33. * device. Currently each device gets 2 pages. We want to fit two requests
  34. * into the available memory so that we can immediately start the next if one
  35. * finishes. */
  36. #define DIAG_MAX_BLOCKS (((2 * PAGE_SIZE - sizeof(struct dasd_ccw_req) - \
  37. sizeof(struct dasd_diag_req)) / \
  38. sizeof(struct dasd_diag_bio)) / 2)
  39. #define DIAG_MAX_RETRIES 32
  40. #define DIAG_TIMEOUT 50
  41. static struct dasd_discipline dasd_diag_discipline;
  42. struct dasd_diag_private {
  43. struct dasd_diag_characteristics rdc_data;
  44. struct dasd_diag_rw_io iob;
  45. struct dasd_diag_init_io iib;
  46. blocknum_t pt_block;
  47. struct ccw_dev_id dev_id;
  48. };
  49. struct dasd_diag_req {
  50. unsigned int block_count;
  51. struct dasd_diag_bio bio[0];
  52. };
  53. static const u8 DASD_DIAG_CMS1[] = { 0xc3, 0xd4, 0xe2, 0xf1 };/* EBCDIC CMS1 */
  54. /* Perform DIAG250 call with block I/O parameter list iob (input and output)
  55. * and function code cmd.
  56. * In case of an exception return 3. Otherwise return result of bitwise OR of
  57. * resulting condition code and DIAG return code. */
  58. static inline int dia250(void *iob, int cmd)
  59. {
  60. register unsigned long reg2 asm ("2") = (unsigned long) iob;
  61. typedef union {
  62. struct dasd_diag_init_io init_io;
  63. struct dasd_diag_rw_io rw_io;
  64. } addr_type;
  65. int rc;
  66. rc = 3;
  67. asm volatile(
  68. " diag 2,%2,0x250\n"
  69. "0: ipm %0\n"
  70. " srl %0,28\n"
  71. " or %0,3\n"
  72. "1:\n"
  73. EX_TABLE(0b,1b)
  74. : "+d" (rc), "=m" (*(addr_type *) iob)
  75. : "d" (cmd), "d" (reg2), "m" (*(addr_type *) iob)
  76. : "3", "cc");
  77. return rc;
  78. }
  79. /* Initialize block I/O to DIAG device using the specified blocksize and
  80. * block offset. On success, return zero and set end_block to contain the
  81. * number of blocks on the device minus the specified offset. Return non-zero
  82. * otherwise. */
  83. static inline int
  84. mdsk_init_io(struct dasd_device *device, unsigned int blocksize,
  85. blocknum_t offset, blocknum_t *end_block)
  86. {
  87. struct dasd_diag_private *private;
  88. struct dasd_diag_init_io *iib;
  89. int rc;
  90. private = (struct dasd_diag_private *) device->private;
  91. iib = &private->iib;
  92. memset(iib, 0, sizeof (struct dasd_diag_init_io));
  93. iib->dev_nr = private->dev_id.devno;
  94. iib->block_size = blocksize;
  95. iib->offset = offset;
  96. iib->flaga = DASD_DIAG_FLAGA_DEFAULT;
  97. rc = dia250(iib, INIT_BIO);
  98. if ((rc & 3) == 0 && end_block)
  99. *end_block = iib->end_block;
  100. return rc;
  101. }
  102. /* Remove block I/O environment for device. Return zero on success, non-zero
  103. * otherwise. */
  104. static inline int
  105. mdsk_term_io(struct dasd_device * device)
  106. {
  107. struct dasd_diag_private *private;
  108. struct dasd_diag_init_io *iib;
  109. int rc;
  110. private = (struct dasd_diag_private *) device->private;
  111. iib = &private->iib;
  112. memset(iib, 0, sizeof (struct dasd_diag_init_io));
  113. iib->dev_nr = private->dev_id.devno;
  114. rc = dia250(iib, TERM_BIO);
  115. return rc;
  116. }
  117. /* Error recovery for failed DIAG requests - try to reestablish the DIAG
  118. * environment. */
  119. static void
  120. dasd_diag_erp(struct dasd_device *device)
  121. {
  122. int rc;
  123. mdsk_term_io(device);
  124. rc = mdsk_init_io(device, device->block->bp_block, 0, NULL);
  125. if (rc == 4) {
  126. if (!(test_and_set_bit(DASD_FLAG_DEVICE_RO, &device->flags)))
  127. pr_warning("%s: The access mode of a DIAG device "
  128. "changed to read-only\n",
  129. dev_name(&device->cdev->dev));
  130. rc = 0;
  131. }
  132. if (rc)
  133. pr_warning("%s: DIAG ERP failed with "
  134. "rc=%d\n", dev_name(&device->cdev->dev), rc);
  135. }
  136. /* Start a given request at the device. Return zero on success, non-zero
  137. * otherwise. */
  138. static int
  139. dasd_start_diag(struct dasd_ccw_req * cqr)
  140. {
  141. struct dasd_device *device;
  142. struct dasd_diag_private *private;
  143. struct dasd_diag_req *dreq;
  144. int rc;
  145. device = cqr->startdev;
  146. if (cqr->retries < 0) {
  147. DBF_DEV_EVENT(DBF_ERR, device, "DIAG start_IO: request %p "
  148. "- no retry left)", cqr);
  149. cqr->status = DASD_CQR_ERROR;
  150. return -EIO;
  151. }
  152. private = (struct dasd_diag_private *) device->private;
  153. dreq = (struct dasd_diag_req *) cqr->data;
  154. private->iob.dev_nr = private->dev_id.devno;
  155. private->iob.key = 0;
  156. private->iob.flags = DASD_DIAG_RWFLAG_ASYNC;
  157. private->iob.block_count = dreq->block_count;
  158. private->iob.interrupt_params = (addr_t) cqr;
  159. private->iob.bio_list = dreq->bio;
  160. private->iob.flaga = DASD_DIAG_FLAGA_DEFAULT;
  161. cqr->startclk = get_clock();
  162. cqr->starttime = jiffies;
  163. cqr->retries--;
  164. rc = dia250(&private->iob, RW_BIO);
  165. switch (rc) {
  166. case 0: /* Synchronous I/O finished successfully */
  167. cqr->stopclk = get_clock();
  168. cqr->status = DASD_CQR_SUCCESS;
  169. /* Indicate to calling function that only a dasd_schedule_bh()
  170. and no timer is needed */
  171. rc = -EACCES;
  172. break;
  173. case 8: /* Asynchronous I/O was started */
  174. cqr->status = DASD_CQR_IN_IO;
  175. rc = 0;
  176. break;
  177. default: /* Error condition */
  178. cqr->status = DASD_CQR_QUEUED;
  179. DBF_DEV_EVENT(DBF_WARNING, device, "dia250 returned rc=%d", rc);
  180. dasd_diag_erp(device);
  181. rc = -EIO;
  182. break;
  183. }
  184. cqr->intrc = rc;
  185. return rc;
  186. }
  187. /* Terminate given request at the device. */
  188. static int
  189. dasd_diag_term_IO(struct dasd_ccw_req * cqr)
  190. {
  191. struct dasd_device *device;
  192. device = cqr->startdev;
  193. mdsk_term_io(device);
  194. mdsk_init_io(device, device->block->bp_block, 0, NULL);
  195. cqr->status = DASD_CQR_CLEAR_PENDING;
  196. cqr->stopclk = get_clock();
  197. dasd_schedule_device_bh(device);
  198. return 0;
  199. }
  200. /* Handle external interruption. */
  201. static void dasd_ext_handler(struct ext_code ext_code,
  202. unsigned int param32, unsigned long param64)
  203. {
  204. struct dasd_ccw_req *cqr, *next;
  205. struct dasd_device *device;
  206. unsigned long long expires;
  207. unsigned long flags;
  208. addr_t ip;
  209. int rc;
  210. switch (ext_code.subcode >> 8) {
  211. case DASD_DIAG_CODE_31BIT:
  212. ip = (addr_t) param32;
  213. break;
  214. case DASD_DIAG_CODE_64BIT:
  215. ip = (addr_t) param64;
  216. break;
  217. default:
  218. return;
  219. }
  220. kstat_cpu(smp_processor_id()).irqs[EXTINT_DSD]++;
  221. if (!ip) { /* no intparm: unsolicited interrupt */
  222. DBF_EVENT(DBF_NOTICE, "%s", "caught unsolicited "
  223. "interrupt");
  224. return;
  225. }
  226. cqr = (struct dasd_ccw_req *) ip;
  227. device = (struct dasd_device *) cqr->startdev;
  228. if (strncmp(device->discipline->ebcname, (char *) &cqr->magic, 4)) {
  229. DBF_DEV_EVENT(DBF_WARNING, device,
  230. " magic number of dasd_ccw_req 0x%08X doesn't"
  231. " match discipline 0x%08X",
  232. cqr->magic, *(int *) (&device->discipline->name));
  233. return;
  234. }
  235. /* get irq lock to modify request queue */
  236. spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags);
  237. /* Check for a pending clear operation */
  238. if (cqr->status == DASD_CQR_CLEAR_PENDING) {
  239. cqr->status = DASD_CQR_CLEARED;
  240. dasd_device_clear_timer(device);
  241. dasd_schedule_device_bh(device);
  242. spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
  243. return;
  244. }
  245. cqr->stopclk = get_clock();
  246. expires = 0;
  247. if ((ext_code.subcode & 0xff) == 0) {
  248. cqr->status = DASD_CQR_SUCCESS;
  249. /* Start first request on queue if possible -> fast_io. */
  250. if (!list_empty(&device->ccw_queue)) {
  251. next = list_entry(device->ccw_queue.next,
  252. struct dasd_ccw_req, devlist);
  253. if (next->status == DASD_CQR_QUEUED) {
  254. rc = dasd_start_diag(next);
  255. if (rc == 0)
  256. expires = next->expires;
  257. }
  258. }
  259. } else {
  260. cqr->status = DASD_CQR_QUEUED;
  261. DBF_DEV_EVENT(DBF_DEBUG, device, "interrupt status for "
  262. "request %p was %d (%d retries left)", cqr,
  263. ext_code.subcode & 0xff, cqr->retries);
  264. dasd_diag_erp(device);
  265. }
  266. if (expires != 0)
  267. dasd_device_set_timer(device, expires);
  268. else
  269. dasd_device_clear_timer(device);
  270. dasd_schedule_device_bh(device);
  271. spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags);
  272. }
  273. /* Check whether device can be controlled by DIAG discipline. Return zero on
  274. * success, non-zero otherwise. */
  275. static int
  276. dasd_diag_check_device(struct dasd_device *device)
  277. {
  278. struct dasd_block *block;
  279. struct dasd_diag_private *private;
  280. struct dasd_diag_characteristics *rdc_data;
  281. struct dasd_diag_bio bio;
  282. struct vtoc_cms_label *label;
  283. blocknum_t end_block;
  284. unsigned int sb, bsize;
  285. int rc;
  286. private = (struct dasd_diag_private *) device->private;
  287. if (private == NULL) {
  288. private = kzalloc(sizeof(struct dasd_diag_private),GFP_KERNEL);
  289. if (private == NULL) {
  290. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  291. "Allocating memory for private DASD data "
  292. "failed\n");
  293. return -ENOMEM;
  294. }
  295. ccw_device_get_id(device->cdev, &private->dev_id);
  296. device->private = (void *) private;
  297. }
  298. block = dasd_alloc_block();
  299. if (IS_ERR(block)) {
  300. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  301. "could not allocate dasd block structure");
  302. device->private = NULL;
  303. kfree(private);
  304. return PTR_ERR(block);
  305. }
  306. device->block = block;
  307. block->base = device;
  308. /* Read Device Characteristics */
  309. rdc_data = (void *) &(private->rdc_data);
  310. rdc_data->dev_nr = private->dev_id.devno;
  311. rdc_data->rdc_len = sizeof (struct dasd_diag_characteristics);
  312. rc = diag210((struct diag210 *) rdc_data);
  313. if (rc) {
  314. DBF_DEV_EVENT(DBF_WARNING, device, "failed to retrieve device "
  315. "information (rc=%d)", rc);
  316. rc = -EOPNOTSUPP;
  317. goto out;
  318. }
  319. device->default_expires = DIAG_TIMEOUT;
  320. /* Figure out position of label block */
  321. switch (private->rdc_data.vdev_class) {
  322. case DEV_CLASS_FBA:
  323. private->pt_block = 1;
  324. break;
  325. case DEV_CLASS_ECKD:
  326. private->pt_block = 2;
  327. break;
  328. default:
  329. pr_warning("%s: Device type %d is not supported "
  330. "in DIAG mode\n", dev_name(&device->cdev->dev),
  331. private->rdc_data.vdev_class);
  332. rc = -EOPNOTSUPP;
  333. goto out;
  334. }
  335. DBF_DEV_EVENT(DBF_INFO, device,
  336. "%04X: %04X on real %04X/%02X",
  337. rdc_data->dev_nr,
  338. rdc_data->vdev_type,
  339. rdc_data->rdev_type, rdc_data->rdev_model);
  340. /* terminate all outstanding operations */
  341. mdsk_term_io(device);
  342. /* figure out blocksize of device */
  343. label = (struct vtoc_cms_label *) get_zeroed_page(GFP_KERNEL);
  344. if (label == NULL) {
  345. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  346. "No memory to allocate initialization request");
  347. rc = -ENOMEM;
  348. goto out;
  349. }
  350. rc = 0;
  351. end_block = 0;
  352. /* try all sizes - needed for ECKD devices */
  353. for (bsize = 512; bsize <= PAGE_SIZE; bsize <<= 1) {
  354. mdsk_init_io(device, bsize, 0, &end_block);
  355. memset(&bio, 0, sizeof (struct dasd_diag_bio));
  356. bio.type = MDSK_READ_REQ;
  357. bio.block_number = private->pt_block + 1;
  358. bio.buffer = label;
  359. memset(&private->iob, 0, sizeof (struct dasd_diag_rw_io));
  360. private->iob.dev_nr = rdc_data->dev_nr;
  361. private->iob.key = 0;
  362. private->iob.flags = 0; /* do synchronous io */
  363. private->iob.block_count = 1;
  364. private->iob.interrupt_params = 0;
  365. private->iob.bio_list = &bio;
  366. private->iob.flaga = DASD_DIAG_FLAGA_DEFAULT;
  367. rc = dia250(&private->iob, RW_BIO);
  368. if (rc == 3) {
  369. pr_warning("%s: A 64-bit DIAG call failed\n",
  370. dev_name(&device->cdev->dev));
  371. rc = -EOPNOTSUPP;
  372. goto out_label;
  373. }
  374. mdsk_term_io(device);
  375. if (rc == 0)
  376. break;
  377. }
  378. if (bsize > PAGE_SIZE) {
  379. pr_warning("%s: Accessing the DASD failed because of an "
  380. "incorrect format (rc=%d)\n",
  381. dev_name(&device->cdev->dev), rc);
  382. rc = -EIO;
  383. goto out_label;
  384. }
  385. /* check for label block */
  386. if (memcmp(label->label_id, DASD_DIAG_CMS1,
  387. sizeof(DASD_DIAG_CMS1)) == 0) {
  388. /* get formatted blocksize from label block */
  389. bsize = (unsigned int) label->block_size;
  390. block->blocks = (unsigned long) label->block_count;
  391. } else
  392. block->blocks = end_block;
  393. block->bp_block = bsize;
  394. block->s2b_shift = 0; /* bits to shift 512 to get a block */
  395. for (sb = 512; sb < bsize; sb = sb << 1)
  396. block->s2b_shift++;
  397. rc = mdsk_init_io(device, block->bp_block, 0, NULL);
  398. if (rc && (rc != 4)) {
  399. pr_warning("%s: DIAG initialization failed with rc=%d\n",
  400. dev_name(&device->cdev->dev), rc);
  401. rc = -EIO;
  402. } else {
  403. if (rc == 4)
  404. set_bit(DASD_FLAG_DEVICE_RO, &device->flags);
  405. pr_info("%s: New DASD with %ld byte/block, total size %ld "
  406. "KB%s\n", dev_name(&device->cdev->dev),
  407. (unsigned long) block->bp_block,
  408. (unsigned long) (block->blocks <<
  409. block->s2b_shift) >> 1,
  410. (rc == 4) ? ", read-only device" : "");
  411. rc = 0;
  412. }
  413. out_label:
  414. free_page((long) label);
  415. out:
  416. if (rc) {
  417. device->block = NULL;
  418. dasd_free_block(block);
  419. device->private = NULL;
  420. kfree(private);
  421. }
  422. return rc;
  423. }
  424. /* Fill in virtual disk geometry for device. Return zero on success, non-zero
  425. * otherwise. */
  426. static int
  427. dasd_diag_fill_geometry(struct dasd_block *block, struct hd_geometry *geo)
  428. {
  429. if (dasd_check_blocksize(block->bp_block) != 0)
  430. return -EINVAL;
  431. geo->cylinders = (block->blocks << block->s2b_shift) >> 10;
  432. geo->heads = 16;
  433. geo->sectors = 128 >> block->s2b_shift;
  434. return 0;
  435. }
  436. static dasd_erp_fn_t
  437. dasd_diag_erp_action(struct dasd_ccw_req * cqr)
  438. {
  439. return dasd_default_erp_action;
  440. }
  441. static dasd_erp_fn_t
  442. dasd_diag_erp_postaction(struct dasd_ccw_req * cqr)
  443. {
  444. return dasd_default_erp_postaction;
  445. }
  446. /* Create DASD request from block device request. Return pointer to new
  447. * request on success, ERR_PTR otherwise. */
  448. static struct dasd_ccw_req *dasd_diag_build_cp(struct dasd_device *memdev,
  449. struct dasd_block *block,
  450. struct request *req)
  451. {
  452. struct dasd_ccw_req *cqr;
  453. struct dasd_diag_req *dreq;
  454. struct dasd_diag_bio *dbio;
  455. struct req_iterator iter;
  456. struct bio_vec *bv;
  457. char *dst;
  458. unsigned int count, datasize;
  459. sector_t recid, first_rec, last_rec;
  460. unsigned int blksize, off;
  461. unsigned char rw_cmd;
  462. if (rq_data_dir(req) == READ)
  463. rw_cmd = MDSK_READ_REQ;
  464. else if (rq_data_dir(req) == WRITE)
  465. rw_cmd = MDSK_WRITE_REQ;
  466. else
  467. return ERR_PTR(-EINVAL);
  468. blksize = block->bp_block;
  469. /* Calculate record id of first and last block. */
  470. first_rec = blk_rq_pos(req) >> block->s2b_shift;
  471. last_rec =
  472. (blk_rq_pos(req) + blk_rq_sectors(req) - 1) >> block->s2b_shift;
  473. /* Check struct bio and count the number of blocks for the request. */
  474. count = 0;
  475. rq_for_each_segment(bv, req, iter) {
  476. if (bv->bv_len & (blksize - 1))
  477. /* Fba can only do full blocks. */
  478. return ERR_PTR(-EINVAL);
  479. count += bv->bv_len >> (block->s2b_shift + 9);
  480. }
  481. /* Paranoia. */
  482. if (count != last_rec - first_rec + 1)
  483. return ERR_PTR(-EINVAL);
  484. /* Build the request */
  485. datasize = sizeof(struct dasd_diag_req) +
  486. count*sizeof(struct dasd_diag_bio);
  487. cqr = dasd_smalloc_request(DASD_DIAG_MAGIC, 0, datasize, memdev);
  488. if (IS_ERR(cqr))
  489. return cqr;
  490. dreq = (struct dasd_diag_req *) cqr->data;
  491. dreq->block_count = count;
  492. dbio = dreq->bio;
  493. recid = first_rec;
  494. rq_for_each_segment(bv, req, iter) {
  495. dst = page_address(bv->bv_page) + bv->bv_offset;
  496. for (off = 0; off < bv->bv_len; off += blksize) {
  497. memset(dbio, 0, sizeof (struct dasd_diag_bio));
  498. dbio->type = rw_cmd;
  499. dbio->block_number = recid + 1;
  500. dbio->buffer = dst;
  501. dbio++;
  502. dst += blksize;
  503. recid++;
  504. }
  505. }
  506. cqr->retries = DIAG_MAX_RETRIES;
  507. cqr->buildclk = get_clock();
  508. if (blk_noretry_request(req) ||
  509. block->base->features & DASD_FEATURE_FAILFAST)
  510. set_bit(DASD_CQR_FLAGS_FAILFAST, &cqr->flags);
  511. cqr->startdev = memdev;
  512. cqr->memdev = memdev;
  513. cqr->block = block;
  514. cqr->expires = memdev->default_expires * HZ;
  515. cqr->status = DASD_CQR_FILLED;
  516. return cqr;
  517. }
  518. /* Release DASD request. Return non-zero if request was successful, zero
  519. * otherwise. */
  520. static int
  521. dasd_diag_free_cp(struct dasd_ccw_req *cqr, struct request *req)
  522. {
  523. int status;
  524. status = cqr->status == DASD_CQR_DONE;
  525. dasd_sfree_request(cqr, cqr->memdev);
  526. return status;
  527. }
  528. static void dasd_diag_handle_terminated_request(struct dasd_ccw_req *cqr)
  529. {
  530. cqr->status = DASD_CQR_FILLED;
  531. };
  532. /* Fill in IOCTL data for device. */
  533. static int
  534. dasd_diag_fill_info(struct dasd_device * device,
  535. struct dasd_information2_t * info)
  536. {
  537. struct dasd_diag_private *private;
  538. private = (struct dasd_diag_private *) device->private;
  539. info->label_block = (unsigned int) private->pt_block;
  540. info->FBA_layout = 1;
  541. info->format = DASD_FORMAT_LDL;
  542. info->characteristics_size = sizeof (struct dasd_diag_characteristics);
  543. memcpy(info->characteristics,
  544. &((struct dasd_diag_private *) device->private)->rdc_data,
  545. sizeof (struct dasd_diag_characteristics));
  546. info->confdata_size = 0;
  547. return 0;
  548. }
  549. static void
  550. dasd_diag_dump_sense(struct dasd_device *device, struct dasd_ccw_req * req,
  551. struct irb *stat)
  552. {
  553. DBF_DEV_EVENT(DBF_WARNING, device, "%s",
  554. "dump sense not available for DIAG data");
  555. }
  556. static struct dasd_discipline dasd_diag_discipline = {
  557. .owner = THIS_MODULE,
  558. .name = "DIAG",
  559. .ebcname = "DIAG",
  560. .max_blocks = DIAG_MAX_BLOCKS,
  561. .check_device = dasd_diag_check_device,
  562. .verify_path = dasd_generic_verify_path,
  563. .fill_geometry = dasd_diag_fill_geometry,
  564. .start_IO = dasd_start_diag,
  565. .term_IO = dasd_diag_term_IO,
  566. .handle_terminated_request = dasd_diag_handle_terminated_request,
  567. .erp_action = dasd_diag_erp_action,
  568. .erp_postaction = dasd_diag_erp_postaction,
  569. .build_cp = dasd_diag_build_cp,
  570. .free_cp = dasd_diag_free_cp,
  571. .dump_sense = dasd_diag_dump_sense,
  572. .fill_info = dasd_diag_fill_info,
  573. };
  574. static int __init
  575. dasd_diag_init(void)
  576. {
  577. if (!MACHINE_IS_VM) {
  578. pr_info("Discipline %s cannot be used without z/VM\n",
  579. dasd_diag_discipline.name);
  580. return -ENODEV;
  581. }
  582. ASCEBC(dasd_diag_discipline.ebcname, 4);
  583. service_subclass_irq_register();
  584. register_external_interrupt(0x2603, dasd_ext_handler);
  585. dasd_diag_discipline_pointer = &dasd_diag_discipline;
  586. return 0;
  587. }
  588. static void __exit
  589. dasd_diag_cleanup(void)
  590. {
  591. unregister_external_interrupt(0x2603, dasd_ext_handler);
  592. service_subclass_irq_unregister();
  593. dasd_diag_discipline_pointer = NULL;
  594. }
  595. module_init(dasd_diag_init);
  596. module_exit(dasd_diag_cleanup);