diff options
author | Hoang-Nam Nguyen <hnguyen@de.ibm.com> | 2006-10-02 17:52:17 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2006-10-02 17:52:17 -0400 |
commit | 0f248d9cde673a481eb3182909b54d07e9d58f72 (patch) | |
tree | 9e6dd929c0b3ccee9be45c554a596a8370c83318 /drivers/infiniband | |
parent | 13b18c86176cab34ef30ef0a5962fcb0305f7269 (diff) |
IB/ehca: Fix device registration
Move the call to ib_register_device() later, since a device should not
be registered until it is completely read to be used. This fixes
crashes that occur if an upper-layer driver such as IPoIB is loaded
before the ehca module.
Signed-off-by: Hoang-Nam Nguyen <hnguyen@de.ibm.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/hw/ehca/ehca_main.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c index 2380994418a5..024d511c4b58 100644 --- a/drivers/infiniband/hw/ehca/ehca_main.c +++ b/drivers/infiniband/hw/ehca/ehca_main.c | |||
@@ -49,7 +49,7 @@ | |||
49 | MODULE_LICENSE("Dual BSD/GPL"); | 49 | MODULE_LICENSE("Dual BSD/GPL"); |
50 | MODULE_AUTHOR("Christoph Raisch <raisch@de.ibm.com>"); | 50 | MODULE_AUTHOR("Christoph Raisch <raisch@de.ibm.com>"); |
51 | MODULE_DESCRIPTION("IBM eServer HCA InfiniBand Device Driver"); | 51 | MODULE_DESCRIPTION("IBM eServer HCA InfiniBand Device Driver"); |
52 | MODULE_VERSION("SVNEHCA_0016"); | 52 | MODULE_VERSION("SVNEHCA_0017"); |
53 | 53 | ||
54 | int ehca_open_aqp1 = 0; | 54 | int ehca_open_aqp1 = 0; |
55 | int ehca_debug_level = 0; | 55 | int ehca_debug_level = 0; |
@@ -239,7 +239,7 @@ init_node_guid1: | |||
239 | return ret; | 239 | return ret; |
240 | } | 240 | } |
241 | 241 | ||
242 | int ehca_register_device(struct ehca_shca *shca) | 242 | int ehca_init_device(struct ehca_shca *shca) |
243 | { | 243 | { |
244 | int ret; | 244 | int ret; |
245 | 245 | ||
@@ -317,11 +317,6 @@ int ehca_register_device(struct ehca_shca *shca) | |||
317 | /* shca->ib_device.process_mad = ehca_process_mad; */ | 317 | /* shca->ib_device.process_mad = ehca_process_mad; */ |
318 | shca->ib_device.mmap = ehca_mmap; | 318 | shca->ib_device.mmap = ehca_mmap; |
319 | 319 | ||
320 | ret = ib_register_device(&shca->ib_device); | ||
321 | if (ret) | ||
322 | ehca_err(&shca->ib_device, | ||
323 | "ib_register_device() failed ret=%x", ret); | ||
324 | |||
325 | return ret; | 320 | return ret; |
326 | } | 321 | } |
327 | 322 | ||
@@ -561,9 +556,9 @@ static int __devinit ehca_probe(struct ibmebus_dev *dev, | |||
561 | goto probe1; | 556 | goto probe1; |
562 | } | 557 | } |
563 | 558 | ||
564 | ret = ehca_register_device(shca); | 559 | ret = ehca_init_device(shca); |
565 | if (ret) { | 560 | if (ret) { |
566 | ehca_gen_err("Cannot register Infiniband device"); | 561 | ehca_gen_err("Cannot init ehca device struct"); |
567 | goto probe1; | 562 | goto probe1; |
568 | } | 563 | } |
569 | 564 | ||
@@ -571,7 +566,7 @@ static int __devinit ehca_probe(struct ibmebus_dev *dev, | |||
571 | ret = ehca_create_eq(shca, &shca->eq, EHCA_EQ, 2048); | 566 | ret = ehca_create_eq(shca, &shca->eq, EHCA_EQ, 2048); |
572 | if (ret) { | 567 | if (ret) { |
573 | ehca_err(&shca->ib_device, "Cannot create EQ."); | 568 | ehca_err(&shca->ib_device, "Cannot create EQ."); |
574 | goto probe2; | 569 | goto probe1; |
575 | } | 570 | } |
576 | 571 | ||
577 | ret = ehca_create_eq(shca, &shca->neq, EHCA_NEQ, 513); | 572 | ret = ehca_create_eq(shca, &shca->neq, EHCA_NEQ, 513); |
@@ -600,6 +595,13 @@ static int __devinit ehca_probe(struct ibmebus_dev *dev, | |||
600 | goto probe5; | 595 | goto probe5; |
601 | } | 596 | } |
602 | 597 | ||
598 | ret = ib_register_device(&shca->ib_device); | ||
599 | if (ret) { | ||
600 | ehca_err(&shca->ib_device, | ||
601 | "ib_register_device() failed ret=%x", ret); | ||
602 | goto probe6; | ||
603 | } | ||
604 | |||
603 | /* create AQP1 for port 1 */ | 605 | /* create AQP1 for port 1 */ |
604 | if (ehca_open_aqp1 == 1) { | 606 | if (ehca_open_aqp1 == 1) { |
605 | shca->sport[0].port_state = IB_PORT_DOWN; | 607 | shca->sport[0].port_state = IB_PORT_DOWN; |
@@ -607,7 +609,7 @@ static int __devinit ehca_probe(struct ibmebus_dev *dev, | |||
607 | if (ret) { | 609 | if (ret) { |
608 | ehca_err(&shca->ib_device, | 610 | ehca_err(&shca->ib_device, |
609 | "Cannot create AQP1 for port 1."); | 611 | "Cannot create AQP1 for port 1."); |
610 | goto probe6; | 612 | goto probe7; |
611 | } | 613 | } |
612 | } | 614 | } |
613 | 615 | ||
@@ -618,7 +620,7 @@ static int __devinit ehca_probe(struct ibmebus_dev *dev, | |||
618 | if (ret) { | 620 | if (ret) { |
619 | ehca_err(&shca->ib_device, | 621 | ehca_err(&shca->ib_device, |
620 | "Cannot create AQP1 for port 2."); | 622 | "Cannot create AQP1 for port 2."); |
621 | goto probe7; | 623 | goto probe8; |
622 | } | 624 | } |
623 | } | 625 | } |
624 | 626 | ||
@@ -630,12 +632,15 @@ static int __devinit ehca_probe(struct ibmebus_dev *dev, | |||
630 | 632 | ||
631 | return 0; | 633 | return 0; |
632 | 634 | ||
633 | probe7: | 635 | probe8: |
634 | ret = ehca_destroy_aqp1(&shca->sport[0]); | 636 | ret = ehca_destroy_aqp1(&shca->sport[0]); |
635 | if (ret) | 637 | if (ret) |
636 | ehca_err(&shca->ib_device, | 638 | ehca_err(&shca->ib_device, |
637 | "Cannot destroy AQP1 for port 1. ret=%x", ret); | 639 | "Cannot destroy AQP1 for port 1. ret=%x", ret); |
638 | 640 | ||
641 | probe7: | ||
642 | ib_unregister_device(&shca->ib_device); | ||
643 | |||
639 | probe6: | 644 | probe6: |
640 | ret = ehca_dereg_internal_maxmr(shca); | 645 | ret = ehca_dereg_internal_maxmr(shca); |
641 | if (ret) | 646 | if (ret) |
@@ -660,9 +665,6 @@ probe3: | |||
660 | ehca_err(&shca->ib_device, | 665 | ehca_err(&shca->ib_device, |
661 | "Cannot destroy EQ. ret=%x", ret); | 666 | "Cannot destroy EQ. ret=%x", ret); |
662 | 667 | ||
663 | probe2: | ||
664 | ib_unregister_device(&shca->ib_device); | ||
665 | |||
666 | probe1: | 668 | probe1: |
667 | ib_dealloc_device(&shca->ib_device); | 669 | ib_dealloc_device(&shca->ib_device); |
668 | 670 | ||
@@ -750,7 +752,7 @@ int __init ehca_module_init(void) | |||
750 | int ret; | 752 | int ret; |
751 | 753 | ||
752 | printk(KERN_INFO "eHCA Infiniband Device Driver " | 754 | printk(KERN_INFO "eHCA Infiniband Device Driver " |
753 | "(Rel.: SVNEHCA_0016)\n"); | 755 | "(Rel.: SVNEHCA_0017)\n"); |
754 | idr_init(&ehca_qp_idr); | 756 | idr_init(&ehca_qp_idr); |
755 | idr_init(&ehca_cq_idr); | 757 | idr_init(&ehca_cq_idr); |
756 | spin_lock_init(&ehca_qp_idr_lock); | 758 | spin_lock_init(&ehca_qp_idr_lock); |