dev_lim->max_eqs = 1 << (field & 0x7);
MTHCA_GET(field, outbox, QUERY_DEV_LIM_RSVD_MTT_OFFSET);
if (mthca_is_memfree(dev))
- dev_lim->reserved_mtts = ALIGN((1 << (field >> 4)) * sizeof(u64),
+ dev_lim->reserved_mtts = ALIGN((1Ui64 << (field >> 4)) * sizeof(u64),
MTHCA_MTT_SEG_SIZE) / MTHCA_MTT_SEG_SIZE;
else
dev_lim->reserved_mtts = 1 << (field >> 4);
int mthca_init_mr_table(struct mthca_dev *dev)
{
- int err, i;
+ int mpts, mtts, err, i;
err = mthca_alloc_init(&dev->mr_table.mpt_alloc,
(u32)dev->limits.num_mpts,
goto err_fmr_mpt;
}
+ mpts = mtts = 1 << i;
+
+ } else {
+ mpts = dev->limits.num_mtt_segs;
+ mtts = dev->limits.num_mpts;
+ }
+
+ if (!mthca_is_memfree(dev) &&
+ (dev->mthca_flags & MTHCA_FLAG_FMR)) {
+
dev->mr_table.tavor_fmr.mpt_base =
ioremap(dev->mr_table.mpt_base,
- (u32)(1 << i) * sizeof (struct mthca_mpt_entry),
+ mpts * sizeof (struct mthca_mpt_entry),
&dev->mr_table.tavor_fmr.mpt_base_size);
if (!dev->mr_table.tavor_fmr.mpt_base) {
dev->mr_table.tavor_fmr.mtt_base =
ioremap(dev->mr_table.mtt_base,
- (1 << i) * MTHCA_MTT_SEG_SIZE,
+ mtts * MTHCA_MTT_SEG_SIZE,
&dev->mr_table.tavor_fmr.mtt_base_size );
if (!dev->mr_table.tavor_fmr.mtt_base) {
err = -ENOMEM;
goto err_fmr_mtt;
}
+ }
- err = mthca_buddy_init(&dev->mr_table.tavor_fmr.mtt_buddy, i);
+ if (dev->limits.fmr_reserved_mtts) {
+ err = mthca_buddy_init(&dev->mr_table.tavor_fmr.mtt_buddy, fls(mtts - 1));
if (err)
goto err_fmr_mtt_buddy;
/* Prevent regular MRs from using FMR keys */
- err = mthca_buddy_alloc(&dev->mr_table.mtt_buddy, i);
+ err = mthca_buddy_alloc(&dev->mr_table.mtt_buddy, fls(mtts - 1));
if (err)
goto err_reserve_fmr;