aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/viodasd.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/block/viodasd.c')
-rw-r--r--drivers/block/viodasd.c91
1 files changed, 38 insertions, 53 deletions
diff --git a/drivers/block/viodasd.c b/drivers/block/viodasd.c
index a8c8b56b275e..788d93882ab9 100644
--- a/drivers/block/viodasd.c
+++ b/drivers/block/viodasd.c
@@ -28,6 +28,9 @@
28 * All disk operations are performed by sending messages back and forth to 28 * All disk operations are performed by sending messages back and forth to
29 * the OS/400 partition. 29 * the OS/400 partition.
30 */ 30 */
31
32#define pr_fmt(fmt) "viod: " fmt
33
31#include <linux/major.h> 34#include <linux/major.h>
32#include <linux/fs.h> 35#include <linux/fs.h>
33#include <linux/module.h> 36#include <linux/module.h>
@@ -63,9 +66,6 @@ MODULE_LICENSE("GPL");
63 66
64#define VIOD_VERS "1.64" 67#define VIOD_VERS "1.64"
65 68
66#define VIOD_KERN_WARNING KERN_WARNING "viod: "
67#define VIOD_KERN_INFO KERN_INFO "viod: "
68
69enum { 69enum {
70 PARTITION_SHIFT = 3, 70 PARTITION_SHIFT = 3,
71 MAX_DISKNO = HVMAXARCHITECTEDVIRTUALDISKS, 71 MAX_DISKNO = HVMAXARCHITECTEDVIRTUALDISKS,
@@ -156,7 +156,7 @@ static int viodasd_open(struct block_device *bdev, fmode_t mode)
156 ((u64)DEVICE_NO(d) << 48) | ((u64)flags << 32), 156 ((u64)DEVICE_NO(d) << 48) | ((u64)flags << 32),
157 0, 0, 0); 157 0, 0, 0);
158 if (hvrc != 0) { 158 if (hvrc != 0) {
159 printk(VIOD_KERN_WARNING "HV open failed %d\n", (int)hvrc); 159 pr_warning("HV open failed %d\n", (int)hvrc);
160 return -EIO; 160 return -EIO;
161 } 161 }
162 162
@@ -167,9 +167,8 @@ static int viodasd_open(struct block_device *bdev, fmode_t mode)
167 const struct vio_error_entry *err = 167 const struct vio_error_entry *err =
168 vio_lookup_rc(viodasd_err_table, we.sub_result); 168 vio_lookup_rc(viodasd_err_table, we.sub_result);
169 169
170 printk(VIOD_KERN_WARNING 170 pr_warning("bad rc opening disk: %d:0x%04x (%s)\n",
171 "bad rc opening disk: %d:0x%04x (%s)\n", 171 (int)we.rc, we.sub_result, err->msg);
172 (int)we.rc, we.sub_result, err->msg);
173 return -EIO; 172 return -EIO;
174 } 173 }
175 174
@@ -195,8 +194,7 @@ static int viodasd_release(struct gendisk *disk, fmode_t mode)
195 ((u64)DEVICE_NO(d) << 48) /* | ((u64)flags << 32) */, 194 ((u64)DEVICE_NO(d) << 48) /* | ((u64)flags << 32) */,
196 0, 0, 0); 195 0, 0, 0);
197 if (hvrc != 0) 196 if (hvrc != 0)
198 printk(VIOD_KERN_WARNING "HV close call failed %d\n", 197 pr_warning("HV close call failed %d\n", (int)hvrc);
199 (int)hvrc);
200 return 0; 198 return 0;
201} 199}
202 200
@@ -288,8 +286,7 @@ static int send_request(struct request *req)
288 bevent = (struct vioblocklpevent *) 286 bevent = (struct vioblocklpevent *)
289 vio_get_event_buffer(viomajorsubtype_blockio); 287 vio_get_event_buffer(viomajorsubtype_blockio);
290 if (bevent == NULL) { 288 if (bevent == NULL) {
291 printk(VIOD_KERN_WARNING 289 pr_warning("error allocating disk event buffer\n");
292 "error allocating disk event buffer\n");
293 goto error_ret; 290 goto error_ret;
294 } 291 }
295 292
@@ -333,9 +330,8 @@ static int send_request(struct request *req)
333 } 330 }
334 331
335 if (hvrc != HvLpEvent_Rc_Good) { 332 if (hvrc != HvLpEvent_Rc_Good) {
336 printk(VIOD_KERN_WARNING 333 pr_warning("error sending disk event to OS/400 (rc %d)\n",
337 "error sending disk event to OS/400 (rc %d)\n", 334 (int)hvrc);
338 (int)hvrc);
339 goto error_ret; 335 goto error_ret;
340 } 336 }
341 spin_unlock_irqrestore(&viodasd_spinlock, flags); 337 spin_unlock_irqrestore(&viodasd_spinlock, flags);
@@ -402,7 +398,7 @@ retry:
402 ((u64)dev_no << 48) | ((u64)flags<< 32), 398 ((u64)dev_no << 48) | ((u64)flags<< 32),
403 0, 0, 0); 399 0, 0, 0);
404 if (hvrc != 0) { 400 if (hvrc != 0) {
405 printk(VIOD_KERN_WARNING "bad rc on HV open %d\n", (int)hvrc); 401 pr_warning("bad rc on HV open %d\n", (int)hvrc);
406 return 0; 402 return 0;
407 } 403 }
408 404
@@ -416,9 +412,8 @@ retry:
416 goto retry; 412 goto retry;
417 } 413 }
418 if (we.max_disk > (MAX_DISKNO - 1)) { 414 if (we.max_disk > (MAX_DISKNO - 1)) {
419 printk_once(VIOD_KERN_INFO 415 printk_once(KERN_INFO pr_fmt("Only examining the first %d of %d disks connected\n"),
420 "Only examining the first %d of %d disks connected\n", 416 MAX_DISKNO, we.max_disk + 1);
421 MAX_DISKNO, we.max_disk + 1);
422 } 417 }
423 418
424 /* Send the close event to OS/400. We DON'T expect a response */ 419 /* Send the close event to OS/400. We DON'T expect a response */
@@ -432,17 +427,15 @@ retry:
432 ((u64)dev_no << 48) | ((u64)flags << 32), 427 ((u64)dev_no << 48) | ((u64)flags << 32),
433 0, 0, 0); 428 0, 0, 0);
434 if (hvrc != 0) { 429 if (hvrc != 0) {
435 printk(VIOD_KERN_WARNING 430 pr_warning("bad rc sending event to OS/400 %d\n", (int)hvrc);
436 "bad rc sending event to OS/400 %d\n", (int)hvrc);
437 return 0; 431 return 0;
438 } 432 }
439 433
440 if (d->dev == NULL) { 434 if (d->dev == NULL) {
441 /* this is when we reprobe for new disks */ 435 /* this is when we reprobe for new disks */
442 if (vio_create_viodasd(dev_no) == NULL) { 436 if (vio_create_viodasd(dev_no) == NULL) {
443 printk(VIOD_KERN_WARNING 437 pr_warning("cannot allocate virtual device for disk %d\n",
444 "cannot allocate virtual device for disk %d\n", 438 dev_no);
445 dev_no);
446 return 0; 439 return 0;
447 } 440 }
448 /* 441 /*
@@ -457,23 +450,20 @@ retry:
457 spin_lock_init(&d->q_lock); 450 spin_lock_init(&d->q_lock);
458 q = blk_init_queue(do_viodasd_request, &d->q_lock); 451 q = blk_init_queue(do_viodasd_request, &d->q_lock);
459 if (q == NULL) { 452 if (q == NULL) {
460 printk(VIOD_KERN_WARNING "cannot allocate queue for disk %d\n", 453 pr_warning("cannot allocate queue for disk %d\n", dev_no);
461 dev_no);
462 return 0; 454 return 0;
463 } 455 }
464 g = alloc_disk(1 << PARTITION_SHIFT); 456 g = alloc_disk(1 << PARTITION_SHIFT);
465 if (g == NULL) { 457 if (g == NULL) {
466 printk(VIOD_KERN_WARNING 458 pr_warning("cannot allocate disk structure for disk %d\n",
467 "cannot allocate disk structure for disk %d\n", 459 dev_no);
468 dev_no);
469 blk_cleanup_queue(q); 460 blk_cleanup_queue(q);
470 return 0; 461 return 0;
471 } 462 }
472 463
473 d->disk = g; 464 d->disk = g;
474 blk_queue_max_hw_segments(q, VIOMAXBLOCKDMA); 465 blk_queue_max_segments(q, VIOMAXBLOCKDMA);
475 blk_queue_max_phys_segments(q, VIOMAXBLOCKDMA); 466 blk_queue_max_hw_sectors(q, VIODASD_MAXSECTORS);
476 blk_queue_max_sectors(q, VIODASD_MAXSECTORS);
477 g->major = VIODASD_MAJOR; 467 g->major = VIODASD_MAJOR;
478 g->first_minor = dev_no << PARTITION_SHIFT; 468 g->first_minor = dev_no << PARTITION_SHIFT;
479 if (dev_no >= 26) 469 if (dev_no >= 26)
@@ -489,13 +479,12 @@ retry:
489 g->driverfs_dev = d->dev; 479 g->driverfs_dev = d->dev;
490 set_capacity(g, d->size >> 9); 480 set_capacity(g, d->size >> 9);
491 481
492 printk(VIOD_KERN_INFO "disk %d: %lu sectors (%lu MB) " 482 pr_info("disk %d: %lu sectors (%lu MB) CHS=%d/%d/%d sector size %d%s\n",
493 "CHS=%d/%d/%d sector size %d%s\n", 483 dev_no, (unsigned long)(d->size >> 9),
494 dev_no, (unsigned long)(d->size >> 9), 484 (unsigned long)(d->size >> 20),
495 (unsigned long)(d->size >> 20), 485 (int)d->cylinders, (int)d->tracks,
496 (int)d->cylinders, (int)d->tracks, 486 (int)d->sectors, (int)d->bytes_per_sector,
497 (int)d->sectors, (int)d->bytes_per_sector, 487 d->read_only ? " (RO)" : "");
498 d->read_only ? " (RO)" : "");
499 488
500 /* register us in the global list */ 489 /* register us in the global list */
501 add_disk(g); 490 add_disk(g);
@@ -580,8 +569,8 @@ static int viodasd_handle_read_write(struct vioblocklpevent *bevent)
580 if (error) { 569 if (error) {
581 const struct vio_error_entry *err; 570 const struct vio_error_entry *err;
582 err = vio_lookup_rc(viodasd_err_table, bevent->sub_result); 571 err = vio_lookup_rc(viodasd_err_table, bevent->sub_result);
583 printk(VIOD_KERN_WARNING "read/write error %d:0x%04x (%s)\n", 572 pr_warning("read/write error %d:0x%04x (%s)\n",
584 event->xRc, bevent->sub_result, err->msg); 573 event->xRc, bevent->sub_result, err->msg);
585 num_sect = blk_rq_sectors(req); 574 num_sect = blk_rq_sectors(req);
586 } 575 }
587 qlock = req->q->queue_lock; 576 qlock = req->q->queue_lock;
@@ -606,8 +595,7 @@ static void handle_block_event(struct HvLpEvent *event)
606 return; 595 return;
607 /* First, we should NEVER get an int here...only acks */ 596 /* First, we should NEVER get an int here...only acks */
608 if (hvlpevent_is_int(event)) { 597 if (hvlpevent_is_int(event)) {
609 printk(VIOD_KERN_WARNING 598 pr_warning("Yikes! got an int in viodasd event handler!\n");
610 "Yikes! got an int in viodasd event handler!\n");
611 if (hvlpevent_need_ack(event)) { 599 if (hvlpevent_need_ack(event)) {
612 event->xRc = HvLpEvent_Rc_InvalidSubtype; 600 event->xRc = HvLpEvent_Rc_InvalidSubtype;
613 HvCallEvent_ackLpEvent(event); 601 HvCallEvent_ackLpEvent(event);
@@ -650,7 +638,7 @@ static void handle_block_event(struct HvLpEvent *event)
650 break; 638 break;
651 639
652 default: 640 default:
653 printk(VIOD_KERN_WARNING "invalid subtype!"); 641 pr_warning("invalid subtype!");
654 if (hvlpevent_need_ack(event)) { 642 if (hvlpevent_need_ack(event)) {
655 event->xRc = HvLpEvent_Rc_InvalidSubtype; 643 event->xRc = HvLpEvent_Rc_InvalidSubtype;
656 HvCallEvent_ackLpEvent(event); 644 HvCallEvent_ackLpEvent(event);
@@ -739,29 +727,26 @@ static int __init viodasd_init(void)
739 vio_set_hostlp(); 727 vio_set_hostlp();
740 728
741 if (viopath_hostLp == HvLpIndexInvalid) { 729 if (viopath_hostLp == HvLpIndexInvalid) {
742 printk(VIOD_KERN_WARNING "invalid hosting partition\n"); 730 pr_warning("invalid hosting partition\n");
743 rc = -EIO; 731 rc = -EIO;
744 goto early_fail; 732 goto early_fail;
745 } 733 }
746 734
747 printk(VIOD_KERN_INFO "vers " VIOD_VERS ", hosting partition %d\n", 735 pr_info("vers " VIOD_VERS ", hosting partition %d\n", viopath_hostLp);
748 viopath_hostLp);
749 736
750 /* register the block device */ 737 /* register the block device */
751 rc = register_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME); 738 rc = register_blkdev(VIODASD_MAJOR, VIOD_GENHD_NAME);
752 if (rc) { 739 if (rc) {
753 printk(VIOD_KERN_WARNING 740 pr_warning("Unable to get major number %d for %s\n",
754 "Unable to get major number %d for %s\n", 741 VIODASD_MAJOR, VIOD_GENHD_NAME);
755 VIODASD_MAJOR, VIOD_GENHD_NAME);
756 goto early_fail; 742 goto early_fail;
757 } 743 }
758 /* Actually open the path to the hosting partition */ 744 /* Actually open the path to the hosting partition */
759 rc = viopath_open(viopath_hostLp, viomajorsubtype_blockio, 745 rc = viopath_open(viopath_hostLp, viomajorsubtype_blockio,
760 VIOMAXREQ + 2); 746 VIOMAXREQ + 2);
761 if (rc) { 747 if (rc) {
762 printk(VIOD_KERN_WARNING 748 pr_warning("error opening path to host partition %d\n",
763 "error opening path to host partition %d\n", 749 viopath_hostLp);
764 viopath_hostLp);
765 goto unregister_blk; 750 goto unregister_blk;
766 } 751 }
767 752
@@ -770,7 +755,7 @@ static int __init viodasd_init(void)
770 755
771 rc = vio_register_driver(&viodasd_driver); 756 rc = vio_register_driver(&viodasd_driver);
772 if (rc) { 757 if (rc) {
773 printk(VIOD_KERN_WARNING "vio_register_driver failed\n"); 758 pr_warning("vio_register_driver failed\n");
774 goto unset_handler; 759 goto unset_handler;
775 } 760 }
776 761