aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/infiniband/hw/mthca/mthca_main.c113
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c2
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.h2
-rw-r--r--include/rdma/ib_verbs.h9
4 files changed, 107 insertions, 19 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index 0491ec7a7c0a..44bc6cc734ab 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -80,24 +80,61 @@ static int tune_pci = 0;
80module_param(tune_pci, int, 0444); 80module_param(tune_pci, int, 0444);
81MODULE_PARM_DESC(tune_pci, "increase PCI burst from the default set by BIOS if nonzero"); 81MODULE_PARM_DESC(tune_pci, "increase PCI burst from the default set by BIOS if nonzero");
82 82
83struct mutex mthca_device_mutex; 83DEFINE_MUTEX(mthca_device_mutex);
84
85#define MTHCA_DEFAULT_NUM_QP (1 << 16)
86#define MTHCA_DEFAULT_RDB_PER_QP (1 << 2)
87#define MTHCA_DEFAULT_NUM_CQ (1 << 16)
88#define MTHCA_DEFAULT_NUM_MCG (1 << 13)
89#define MTHCA_DEFAULT_NUM_MPT (1 << 17)
90#define MTHCA_DEFAULT_NUM_MTT (1 << 20)
91#define MTHCA_DEFAULT_NUM_UDAV (1 << 15)
92#define MTHCA_DEFAULT_NUM_RESERVED_MTTS (1 << 18)
93#define MTHCA_DEFAULT_NUM_UARC_SIZE (1 << 18)
94
95static struct mthca_profile hca_profile = {
96 .num_qp = MTHCA_DEFAULT_NUM_QP,
97 .rdb_per_qp = MTHCA_DEFAULT_RDB_PER_QP,
98 .num_cq = MTHCA_DEFAULT_NUM_CQ,
99 .num_mcg = MTHCA_DEFAULT_NUM_MCG,
100 .num_mpt = MTHCA_DEFAULT_NUM_MPT,
101 .num_mtt = MTHCA_DEFAULT_NUM_MTT,
102 .num_udav = MTHCA_DEFAULT_NUM_UDAV, /* Tavor only */
103 .fmr_reserved_mtts = MTHCA_DEFAULT_NUM_RESERVED_MTTS, /* Tavor only */
104 .uarc_size = MTHCA_DEFAULT_NUM_UARC_SIZE, /* Arbel only */
105};
106
107module_param_named(num_qp, hca_profile.num_qp, int, 0444);
108MODULE_PARM_DESC(num_qp, "maximum number of QPs per HCA");
109
110module_param_named(rdb_per_qp, hca_profile.rdb_per_qp, int, 0444);
111MODULE_PARM_DESC(rdb_per_qp, "number of RDB buffers per QP");
112
113module_param_named(num_cq, hca_profile.num_cq, int, 0444);
114MODULE_PARM_DESC(num_cq, "maximum number of CQs per HCA");
115
116module_param_named(num_mcg, hca_profile.num_mcg, int, 0444);
117MODULE_PARM_DESC(num_mcg, "maximum number of multicast groups per HCA");
118
119module_param_named(num_mpt, hca_profile.num_mpt, int, 0444);
120MODULE_PARM_DESC(num_mpt,
121 "maximum number of memory protection table entries per HCA");
122
123module_param_named(num_mtt, hca_profile.num_mtt, int, 0444);
124MODULE_PARM_DESC(num_mtt,
125 "maximum number of memory translation table segments per HCA");
126
127module_param_named(num_udav, hca_profile.num_udav, int, 0444);
128MODULE_PARM_DESC(num_udav, "maximum number of UD address vectors per HCA");
129
130module_param_named(fmr_reserved_mtts, hca_profile.fmr_reserved_mtts, int, 0444);
131MODULE_PARM_DESC(fmr_reserved_mtts,
132 "number of memory translation table segments reserved for FMR");
84 133
85static const char mthca_version[] __devinitdata = 134static const char mthca_version[] __devinitdata =
86 DRV_NAME ": Mellanox InfiniBand HCA driver v" 135 DRV_NAME ": Mellanox InfiniBand HCA driver v"
87 DRV_VERSION " (" DRV_RELDATE ")\n"; 136 DRV_VERSION " (" DRV_RELDATE ")\n";
88 137
89static struct mthca_profile default_profile = {
90 .num_qp = 1 << 16,
91 .rdb_per_qp = 4,
92 .num_cq = 1 << 16,
93 .num_mcg = 1 << 13,
94 .num_mpt = 1 << 17,
95 .num_mtt = 1 << 20,
96 .num_udav = 1 << 15, /* Tavor only */
97 .fmr_reserved_mtts = 1 << 18, /* Tavor only */
98 .uarc_size = 1 << 18, /* Arbel only */
99};
100
101static int mthca_tune_pci(struct mthca_dev *mdev) 138static int mthca_tune_pci(struct mthca_dev *mdev)
102{ 139{
103 int cap; 140 int cap;
@@ -303,7 +340,7 @@ static int mthca_init_tavor(struct mthca_dev *mdev)
303 goto err_disable; 340 goto err_disable;
304 } 341 }
305 342
306 profile = default_profile; 343 profile = hca_profile;
307 profile.num_uar = dev_lim.uar_size / PAGE_SIZE; 344 profile.num_uar = dev_lim.uar_size / PAGE_SIZE;
308 profile.uarc_size = 0; 345 profile.uarc_size = 0;
309 if (mdev->mthca_flags & MTHCA_FLAG_SRQ) 346 if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
@@ -621,7 +658,7 @@ static int mthca_init_arbel(struct mthca_dev *mdev)
621 goto err_stop_fw; 658 goto err_stop_fw;
622 } 659 }
623 660
624 profile = default_profile; 661 profile = hca_profile;
625 profile.num_uar = dev_lim.uar_size / PAGE_SIZE; 662 profile.num_uar = dev_lim.uar_size / PAGE_SIZE;
626 profile.num_udav = 0; 663 profile.num_udav = 0;
627 if (mdev->mthca_flags & MTHCA_FLAG_SRQ) 664 if (mdev->mthca_flags & MTHCA_FLAG_SRQ)
@@ -1278,11 +1315,55 @@ static struct pci_driver mthca_driver = {
1278 .remove = __devexit_p(mthca_remove_one) 1315 .remove = __devexit_p(mthca_remove_one)
1279}; 1316};
1280 1317
1318static void __init __mthca_check_profile_val(const char *name, int *pval,
1319 int pval_default)
1320{
1321 /* value must be positive and power of 2 */
1322 int old_pval = *pval;
1323
1324 if (old_pval <= 0)
1325 *pval = pval_default;
1326 else
1327 *pval = roundup_pow_of_two(old_pval);
1328
1329 if (old_pval != *pval) {
1330 printk(KERN_WARNING PFX "Invalid value %d for %s in module parameter.\n",
1331 old_pval, name);
1332 printk(KERN_WARNING PFX "Corrected %s to %d.\n", name, *pval);
1333 }
1334}
1335
1336#define mthca_check_profile_val(name, default) \
1337 __mthca_check_profile_val(#name, &hca_profile.name, default)
1338
1339static void __init mthca_validate_profile(void)
1340{
1341 mthca_check_profile_val(num_qp, MTHCA_DEFAULT_NUM_QP);
1342 mthca_check_profile_val(rdb_per_qp, MTHCA_DEFAULT_RDB_PER_QP);
1343 mthca_check_profile_val(num_cq, MTHCA_DEFAULT_NUM_CQ);
1344 mthca_check_profile_val(num_mcg, MTHCA_DEFAULT_NUM_MCG);
1345 mthca_check_profile_val(num_mpt, MTHCA_DEFAULT_NUM_MPT);
1346 mthca_check_profile_val(num_mtt, MTHCA_DEFAULT_NUM_MTT);
1347 mthca_check_profile_val(num_udav, MTHCA_DEFAULT_NUM_UDAV);
1348 mthca_check_profile_val(fmr_reserved_mtts, MTHCA_DEFAULT_NUM_RESERVED_MTTS);
1349
1350 if (hca_profile.fmr_reserved_mtts >= hca_profile.num_mtt) {
1351 printk(KERN_WARNING PFX "Invalid fmr_reserved_mtts module parameter %d.\n",
1352 hca_profile.fmr_reserved_mtts);
1353 printk(KERN_WARNING PFX "(Must be smaller than num_mtt %d)\n",
1354 hca_profile.num_mtt);
1355 hca_profile.fmr_reserved_mtts = hca_profile.num_mtt / 2;
1356 printk(KERN_WARNING PFX "Corrected fmr_reserved_mtts to %d.\n",
1357 hca_profile.fmr_reserved_mtts);
1358 }
1359}
1360
1281static int __init mthca_init(void) 1361static int __init mthca_init(void)
1282{ 1362{
1283 int ret; 1363 int ret;
1284 1364
1285 mutex_init(&mthca_device_mutex); 1365 mthca_validate_profile();
1366
1286 ret = mthca_catas_init(); 1367 ret = mthca_catas_init();
1287 if (ret) 1368 if (ret)
1288 return ret; 1369 return ret;
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index e9b6a6f07dd7..cdecbf5911c8 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1898,7 +1898,7 @@ static void srp_add_one(struct ib_device *device)
1898 */ 1898 */
1899 srp_dev->fmr_page_shift = max(9, ffs(dev_attr->page_size_cap) - 1); 1899 srp_dev->fmr_page_shift = max(9, ffs(dev_attr->page_size_cap) - 1);
1900 srp_dev->fmr_page_size = 1 << srp_dev->fmr_page_shift; 1900 srp_dev->fmr_page_size = 1 << srp_dev->fmr_page_shift;
1901 srp_dev->fmr_page_mask = ~((unsigned long) srp_dev->fmr_page_size - 1); 1901 srp_dev->fmr_page_mask = ~((u64) srp_dev->fmr_page_size - 1);
1902 1902
1903 INIT_LIST_HEAD(&srp_dev->dev_list); 1903 INIT_LIST_HEAD(&srp_dev->dev_list);
1904 1904
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index 868a540ef7cd..c21772317b86 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -87,7 +87,7 @@ struct srp_device {
87 struct ib_fmr_pool *fmr_pool; 87 struct ib_fmr_pool *fmr_pool;
88 int fmr_page_shift; 88 int fmr_page_shift;
89 int fmr_page_size; 89 int fmr_page_size;
90 unsigned long fmr_page_mask; 90 u64 fmr_page_mask;
91}; 91};
92 92
93struct srp_host { 93struct srp_host {
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 3c2e10574b23..0bfa3328d686 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -1639,7 +1639,14 @@ static inline void *ib_dma_alloc_coherent(struct ib_device *dev,
1639{ 1639{
1640 if (dev->dma_ops) 1640 if (dev->dma_ops)
1641 return dev->dma_ops->alloc_coherent(dev, size, dma_handle, flag); 1641 return dev->dma_ops->alloc_coherent(dev, size, dma_handle, flag);
1642 return dma_alloc_coherent(dev->dma_device, size, dma_handle, flag); 1642 else {
1643 dma_addr_t handle;
1644 void *ret;
1645
1646 ret = dma_alloc_coherent(dev->dma_device, size, &handle, flag);
1647 *dma_handle = handle;
1648 return ret;
1649 }
1643} 1650}
1644 1651
1645/** 1652/**