diff options
Diffstat (limited to 'drivers/infiniband/hw')
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_cmd.c | 21 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_cmd.h | 2 | ||||
-rw-r--r-- | drivers/infiniband/hw/mthca/mthca_main.c | 23 |
3 files changed, 30 insertions, 16 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c index cd9ed958d92f..78d4891720e9 100644 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c | |||
@@ -431,6 +431,27 @@ static int mthca_cmd_imm(struct mthca_dev *dev, | |||
431 | timeout, status); | 431 | timeout, status); |
432 | } | 432 | } |
433 | 433 | ||
434 | int mthca_cmd_init(struct mthca_dev *dev) | ||
435 | { | ||
436 | sema_init(&dev->cmd.hcr_sem, 1); | ||
437 | sema_init(&dev->cmd.poll_sem, 1); | ||
438 | dev->cmd.use_events = 0; | ||
439 | |||
440 | dev->hcr = ioremap(pci_resource_start(dev->pdev, 0) + MTHCA_HCR_BASE, | ||
441 | MTHCA_HCR_SIZE); | ||
442 | if (!dev->hcr) { | ||
443 | mthca_err(dev, "Couldn't map command register."); | ||
444 | return -ENOMEM; | ||
445 | } | ||
446 | |||
447 | return 0; | ||
448 | } | ||
449 | |||
450 | void mthca_cmd_cleanup(struct mthca_dev *dev) | ||
451 | { | ||
452 | iounmap(dev->hcr); | ||
453 | } | ||
454 | |||
434 | /* | 455 | /* |
435 | * Switch to using events to issue FW commands (should be called after | 456 | * Switch to using events to issue FW commands (should be called after |
436 | * event queue to command events has been initialized). | 457 | * event queue to command events has been initialized). |
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.h b/drivers/infiniband/hw/mthca/mthca_cmd.h index adf039b3c540..a8d4231e886a 100644 --- a/drivers/infiniband/hw/mthca/mthca_cmd.h +++ b/drivers/infiniband/hw/mthca/mthca_cmd.h | |||
@@ -235,6 +235,8 @@ struct mthca_set_ib_param { | |||
235 | u32 cap_mask; | 235 | u32 cap_mask; |
236 | }; | 236 | }; |
237 | 237 | ||
238 | int mthca_cmd_init(struct mthca_dev *dev); | ||
239 | void mthca_cmd_cleanup(struct mthca_dev *dev); | ||
238 | int mthca_cmd_use_events(struct mthca_dev *dev); | 240 | int mthca_cmd_use_events(struct mthca_dev *dev); |
239 | void mthca_cmd_use_polling(struct mthca_dev *dev); | 241 | void mthca_cmd_use_polling(struct mthca_dev *dev); |
240 | void mthca_cmd_event(struct mthca_dev *dev, u16 token, | 242 | void mthca_cmd_event(struct mthca_dev *dev, u16 token, |
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c index 7f8106a0f2b0..09519b604c08 100644 --- a/drivers/infiniband/hw/mthca/mthca_main.c +++ b/drivers/infiniband/hw/mthca/mthca_main.c | |||
@@ -1005,25 +1005,18 @@ static int __devinit mthca_init_one(struct pci_dev *pdev, | |||
1005 | !pci_enable_msi(pdev)) | 1005 | !pci_enable_msi(pdev)) |
1006 | mdev->mthca_flags |= MTHCA_FLAG_MSI; | 1006 | mdev->mthca_flags |= MTHCA_FLAG_MSI; |
1007 | 1007 | ||
1008 | sema_init(&mdev->cmd.hcr_sem, 1); | 1008 | if (mthca_cmd_init(mdev)) { |
1009 | sema_init(&mdev->cmd.poll_sem, 1); | 1009 | mthca_err(mdev, "Failed to init command interface, aborting.\n"); |
1010 | mdev->cmd.use_events = 0; | ||
1011 | |||
1012 | mdev->hcr = ioremap(pci_resource_start(pdev, 0) + MTHCA_HCR_BASE, MTHCA_HCR_SIZE); | ||
1013 | if (!mdev->hcr) { | ||
1014 | mthca_err(mdev, "Couldn't map command register, " | ||
1015 | "aborting.\n"); | ||
1016 | err = -ENOMEM; | ||
1017 | goto err_free_dev; | 1010 | goto err_free_dev; |
1018 | } | 1011 | } |
1019 | 1012 | ||
1020 | err = mthca_tune_pci(mdev); | 1013 | err = mthca_tune_pci(mdev); |
1021 | if (err) | 1014 | if (err) |
1022 | goto err_iounmap; | 1015 | goto err_cmd; |
1023 | 1016 | ||
1024 | err = mthca_init_hca(mdev); | 1017 | err = mthca_init_hca(mdev); |
1025 | if (err) | 1018 | if (err) |
1026 | goto err_iounmap; | 1019 | goto err_cmd; |
1027 | 1020 | ||
1028 | if (mdev->fw_ver < mthca_hca_table[id->driver_data].latest_fw) { | 1021 | if (mdev->fw_ver < mthca_hca_table[id->driver_data].latest_fw) { |
1029 | mthca_warn(mdev, "HCA FW version %x.%x.%x is old (%x.%x.%x is current).\n", | 1022 | mthca_warn(mdev, "HCA FW version %x.%x.%x is old (%x.%x.%x is current).\n", |
@@ -1071,8 +1064,8 @@ err_cleanup: | |||
1071 | err_close: | 1064 | err_close: |
1072 | mthca_close_hca(mdev); | 1065 | mthca_close_hca(mdev); |
1073 | 1066 | ||
1074 | err_iounmap: | 1067 | err_cmd: |
1075 | iounmap(mdev->hcr); | 1068 | mthca_cmd_cleanup(mdev); |
1076 | 1069 | ||
1077 | err_free_dev: | 1070 | err_free_dev: |
1078 | if (mdev->mthca_flags & MTHCA_FLAG_MSI_X) | 1071 | if (mdev->mthca_flags & MTHCA_FLAG_MSI_X) |
@@ -1119,10 +1112,8 @@ static void __devexit mthca_remove_one(struct pci_dev *pdev) | |||
1119 | iounmap(mdev->kar); | 1112 | iounmap(mdev->kar); |
1120 | mthca_uar_free(mdev, &mdev->driver_uar); | 1113 | mthca_uar_free(mdev, &mdev->driver_uar); |
1121 | mthca_cleanup_uar_table(mdev); | 1114 | mthca_cleanup_uar_table(mdev); |
1122 | |||
1123 | mthca_close_hca(mdev); | 1115 | mthca_close_hca(mdev); |
1124 | 1116 | mthca_cmd_cleanup(mdev); | |
1125 | iounmap(mdev->hcr); | ||
1126 | 1117 | ||
1127 | if (mdev->mthca_flags & MTHCA_FLAG_MSI_X) | 1118 | if (mdev->mthca_flags & MTHCA_FLAG_MSI_X) |
1128 | pci_disable_msix(pdev); | 1119 | pci_disable_msix(pdev); |