if (mthca_alloc_mtt(dev, i, dev->mr_table.fmr_mtt_buddy) == -1) {
if (mthca_alloc_mtt_range(dev, i, dev->mr_table.fmr_mtt_buddy) == -1) {
int __devinit mthca_init_mr_table(struct mthca_dev *dev){	int err, i;	err = mthca_alloc_init(&dev->mr_table.mpt_alloc,			       dev->limits.num_mpts,			       ~0, dev->limits.reserved_mrws);	if (err)		return err;	if (!mthca_is_memfree(dev) &&	    (dev->mthca_flags & MTHCA_FLAG_DDR_HIDDEN))		dev->limits.fmr_reserved_mtts = 0;	else		dev->mthca_flags |= MTHCA_FLAG_FMR;	err = mthca_buddy_init(&dev->mr_table.mtt_buddy,			       fls(dev->limits.num_mtt_segs - 1));	if (err)		goto err_mtt_buddy;	dev->mr_table.tavor_fmr.mpt_base = NULL;	dev->mr_table.tavor_fmr.mtt_base = NULL;	if (dev->limits.fmr_reserved_mtts) {		i = fls(dev->limits.fmr_reserved_mtts - 1);		if (i >= 31) {			mthca_warn(dev, "Unable to reserve 2^31 FMR MTTs.\n");			err = -EINVAL;			goto err_fmr_mpt;		}		dev->mr_table.tavor_fmr.mpt_base =		       	ioremap(dev->mr_table.mpt_base,				(1 << i) * sizeof (struct mthca_mpt_entry));		if (!dev->mr_table.tavor_fmr.mpt_base) {			mthca_warn(dev, "MPT ioremap for FMR failed.\n");			err = -ENOMEM;			goto err_fmr_mpt;		}		dev->mr_table.tavor_fmr.mtt_base =			ioremap(dev->mr_table.mtt_base,				(1 << i) * MTHCA_MTT_SEG_SIZE);		if (!dev->mr_table.tavor_fmr.mtt_base) {			mthca_warn(dev, "MTT ioremap for FMR failed.\n");			err = -ENOMEM;			goto err_fmr_mtt;		}		err = mthca_buddy_init(&dev->mr_table.tavor_fmr.mtt_buddy, i);		if (err)			goto err_fmr_mtt_buddy;		/* Prevent regular MRs from using FMR keys */		err = mthca_buddy_alloc(&dev->mr_table.mtt_buddy, i);		if (err)			goto err_reserve_fmr;		dev->mr_table.fmr_mtt_buddy =		       	&dev->mr_table.tavor_fmr.mtt_buddy;	} else		dev->mr_table.fmr_mtt_buddy = &dev->mr_table.mtt_buddy;	/* FMR table is always the first, take reserved MTTs out of there */	if (dev->limits.reserved_mtts) {		i = fls(dev->limits.reserved_mtts - 1);		if (mthca_alloc_mtt(dev, i, dev->mr_table.fmr_mtt_buddy) == -1) {			mthca_warn(dev, "MTT table of order %d is too small.\n",				  dev->mr_table.fmr_mtt_buddy->max_order);			err = -ENOMEM;			goto err_reserve_mtts;		}	}	return 0;err_reserve_mtts:err_reserve_fmr:	if (dev->limits.fmr_reserved_mtts)		mthca_buddy_cleanup(&dev->mr_table.tavor_fmr.mtt_buddy);err_fmr_mtt_buddy:	if (dev->mr_table.tavor_fmr.mtt_base)		iounmap(dev->mr_table.tavor_fmr.mtt_base);err_fmr_mtt:	if (dev->mr_table.tavor_fmr.mpt_base)		iounmap(dev->mr_table.tavor_fmr.mpt_base);err_fmr_mpt:	mthca_buddy_cleanup(&dev->mr_table.mtt_buddy);err_mtt_buddy:	mthca_alloc_cleanup(&dev->mr_table.mpt_alloc);	return err;}